aboutsummaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authordrh <>2024-01-31 15:20:13 +0000
committerdrh <>2024-01-31 15:20:13 +0000
commit744581d3d63e653023de977d6375ededaa090014 (patch)
treee161741181fa9de37d04657a95f703c5ba9afd75 /src/json.c
parent9486178f39fe31e24ead8a196cf158829f78daf3 (diff)
downloadsqlite-744581d3d63e653023de977d6375ededaa090014.tar.gz
sqlite-744581d3d63e653023de977d6375ededaa090014.zip
Add NEVER() and ALWAYS() macros for the JSON5-control-character change.
Also fix an incorrect comparison used to determine if a buffer needed to be resized. FossilOrigin-Name: e3c0c0e686f3b7710f79587cf465b5aac52d8f2f2986a3de885a656f652cbfd3
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/json.c b/src/json.c
index 2d6195b79..47b83f181 100644
--- a/src/json.c
+++ b/src/json.c
@@ -1425,7 +1425,7 @@ static u32 jsonbValidityCheck(
}else if( z[j]<=0x1f ){
/* Control characters in JSON5 string literals are ok */
if( x==JSONB_TEXTJ ) return j+1;
- }else if( z[j]!='\\' || j+1>=k ){
+ }else if( NEVER(z[j]!='\\') || j+1>=k ){
return j+1;
}else if( strchr("\"\\/bfnrt",z[j+1])!=0 ){
j++;
@@ -2223,7 +2223,7 @@ static u32 jsonTranslateBlobToText(
continue;
}
if( zIn[0]<=0x1f ){
- if( pOut->nUsed+7<pOut->nAlloc && jsonStringGrow(pOut,7) ) break;
+ if( pOut->nUsed+7>pOut->nAlloc && jsonStringGrow(pOut,7) ) break;
jsonAppendControlChar(pOut, zIn[0]);
zIn++;
sz2--;
@@ -4419,7 +4419,7 @@ static void jsonErrorFunc(
/* Convert byte-offset s.iErr into a character offset */
u32 k;
assert( s.zJson!=0 ); /* Because s.oom is false */
- for(k=0; k<s.iErr && s.zJson[k]; k++){
+ for(k=0; k<s.iErr && ALWAYS(s.zJson[k]); k++){
if( (s.zJson[k] & 0xc0)!=0x80 ) iErrPos++;
}
iErrPos++;