Skip to content

Commit 10fd66c

Browse files
author
czjaso
committed
Fix collection parsing to reject missing commas between elements
1 parent 4c4f597 commit 10fd66c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

source/core_json.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,7 @@ static bool skipArrayScalars( const char * buf,
960960
{
961961
ret = false;
962962
}
963+
963964
break;
964965
}
965966
}
@@ -1159,14 +1160,22 @@ static JSONStatus_t skipCollection( const char * buf,
11591160
{
11601161
depth--;
11611162

1162-
if( ( skipSpaceAndComma( buf, &i, max ) == true ) &&
1163-
isOpenBracket_( stack[ depth ] ) )
1163+
if( skipSpaceAndComma( buf, &i, max ) == true )
11641164
{
11651165
if( skipScalars( buf, &i, max, stack[ depth ] ) != true )
11661166
{
11671167
ret = JSONIllegalDocument;
11681168
}
11691169
}
1170+
else
1171+
{
1172+
/* After closing a nested collection, if there is no comma found when calling
1173+
* skipSpaceAndComma, then we must be at the end of the parent collection. */
1174+
if( ( i < max ) && !isMatchingBracket_( stack[ depth ], buf[ i ] ) )
1175+
{
1176+
ret = JSONIllegalDocument;
1177+
}
1178+
}
11701179

11711180
break;
11721181
}

0 commit comments

Comments
 (0)