Skip to content
Permalink
Browse files

fixed parsing of empty JSON string; fixed failed tests 206 234

  • Loading branch information
tomatolog committed May 21, 2018
1 parent c24b152 commit 1b8bdde19aaa362785ea4c33bdc019154f8fbac4
Showing with 14 additions and 10 deletions.
  1. +14 −10 src/searchd.cpp
@@ -13705,18 +13705,22 @@ void sphHandleMysqlInsert ( StmtErrorReporter_i & tOut, const SqlStmt_t & tStmt,
int iStrCount = dStrings.GetLength();
dStrings.Add ( nullptr );

// sphJsonParse must be terminated with a double zero however usual CSphString have SAFETY_GAP of 4 zeros
if ( !String2JsonPack ( (char *)tVal.m_sVal.cstr(), tStrings.m_dParserBuf, sError, sWarning ) )
break;

if ( tStrings.m_dParserBuf.GetLength() )
// empty source string means NULL attribute
if ( !tVal.m_sVal.IsEmpty() )
{
tStrings.m_dOff[iStrCount] = tStrings.m_dPackedData.GetLength();
// sphJsonParse must be terminated with a double zero however usual CSphString have SAFETY_GAP of 4 zeros
if ( !String2JsonPack ( (char *)tVal.m_sVal.cstr(), tStrings.m_dParserBuf, sError, sWarning ) )
break;

const int iLenBytes = 4;
BYTE * pPacked = tStrings.m_dPackedData.AddN ( iLenBytes + tStrings.m_dParserBuf.GetLength() );
sphPackStrlen ( pPacked, tStrings.m_dParserBuf.GetLength() );
memcpy ( pPacked + iLenBytes, tStrings.m_dParserBuf.Begin(), tStrings.m_dParserBuf.GetLength() );
if ( tStrings.m_dParserBuf.GetLength() )
{
tStrings.m_dOff[iStrCount] = tStrings.m_dPackedData.GetLength();

const int iLenBytes = 4;
BYTE * pPacked = tStrings.m_dPackedData.AddN ( iLenBytes + tStrings.m_dParserBuf.GetLength() );
sphPackStrlen ( pPacked, tStrings.m_dParserBuf.GetLength() );
memcpy ( pPacked + iLenBytes, tStrings.m_dParserBuf.Begin(), tStrings.m_dParserBuf.GetLength() );
}
}
}
}

0 comments on commit 1b8bdde

Please sign in to comment.
You can’t perform that action at this time.