diff options
author | drh <> | 2023-12-12 18:38:53 +0000 |
---|---|---|
committer | drh <> | 2023-12-12 18:38:53 +0000 |
commit | 891f1dc0542504fe402d1879651c307ae9355825 (patch) | |
tree | 35e74a5630b1d47160b3473ab2719a7c41b0097e /src/json.c | |
parent | 9710fa119e2d4196b1afbffb1f8b17659b0021f5 (diff) | |
download | sqlite-891f1dc0542504fe402d1879651c307ae9355825.tar.gz sqlite-891f1dc0542504fe402d1879651c307ae9355825.zip |
Fix the JSON object label comparison object so that it works correctly even
if the label ends with escaped whitespace.
FossilOrigin-Name: 4d5353cadd7b7c5f105bc197f3ec739e2d041472d6b3e939654c9f9cfc2749ae
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/json.c b/src/json.c index e94cac6d5..a24a77894 100644 --- a/src/json.c +++ b/src/json.c @@ -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; } /* |