1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

Fix the JSON object label comparison object so that it works correctly even

if the label ends with escaped whitespace.

FossilOrigin-Name: 4d5353cadd7b7c5f105bc197f3ec739e2d041472d6b3e939654c9f9cfc2749ae
This commit is contained in:
drh
2023-12-12 18:38:53 +00:00
parent 9710fa119e
commit 891f1dc054
3 changed files with 16 additions and 12 deletions

View File

@@ -2478,8 +2478,10 @@ static SQLITE_NOINLINE int jsonLabelCompareEscaped(
){
u32 cLeft, cRight;
assert( rawLeft==0 || rawRight==0 );
while( nLeft>0 && nRight>0 ){
if( rawLeft || zLeft[0]!='\\' ){
while( 1 /*exit-by-return*/ ){
if( nLeft==0 ){
cLeft = 0;
}else if( rawLeft || zLeft[0]!='\\' ){
cLeft = ((u8*)zLeft)[0];
zLeft++;
nLeft--;
@@ -2489,7 +2491,9 @@ static SQLITE_NOINLINE int jsonLabelCompareEscaped(
assert( n<=nLeft );
nLeft -= n;
}
if( rawRight || zRight[0]!='\\' ){
if( nRight==0 ){
cRight = 0;
}else if( rawRight || zRight[0]!='\\' ){
cRight = ((u8*)zRight)[0];
zRight++;
nRight--;
@@ -2500,8 +2504,8 @@ static SQLITE_NOINLINE int jsonLabelCompareEscaped(
nRight -= n;
}
if( cLeft!=cRight ) return 0;
if( cLeft==0 ) return 1;
}
return nLeft==0 && nRight==0;
}
/*