Fix jsonParseReset() to properly clear the JsonParse.aBlob element.
FossilOrigin-Name: ab2644aacf4757a51cf62e05cff6711a0a3605d60502a3dd310887df1b993545
This commit is contained in:
parent
c0f8d58b21
commit
ab70266698
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Omit\sprecompiled\sbinaries\sfrom\sthe\ssource\stree.
|
||||
D 2023-11-24T14:03:20.819
|
||||
C Fix\sjsonParseReset()\sto\sproperly\sclear\sthe\sJsonParse.aBlob\selement.
|
||||
D 2023-11-24T14:25:56.679
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -688,7 +688,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
|
||||
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276
|
||||
F src/json.c f8cfdf1d024a7b2c5ad3eae15903a7a83a9b2c8ab61716d219a57600544b712c
|
||||
F src/json.c c6b23115b4561008363346a209b5c8a3538d967b35c63685b2e07dc7de1f1e31
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
|
||||
F src/main.c 1b89f3de98d1b59fec5bac1d66d6ece21f703821b8eaa0d53d9604c35309f6f9
|
||||
@ -2145,8 +2145,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P a838ebcbbd9f554fd84a1d3176fb572faaef7d0ec0675f1a5bf9430865dafae0 4ff103d294b79cf7734e87e94e9d88c0e9f0b087cbb352e6da2f0a3a6b268f46
|
||||
R 0a66dd6facaa7d203b266fe2d20488a5
|
||||
P 7dbc2f496d7a362460bb4c262ecafe5f30e35a8744861163d12c996365c2142f
|
||||
R 1676f3ca8710b44ac390888e709fad02
|
||||
U drh
|
||||
Z 62c86eba16d8545370a182d5ae7c09b8
|
||||
Z 41b7b01f3bc28811bfbbf765da2aea03
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
7dbc2f496d7a362460bb4c262ecafe5f30e35a8744861163d12c996365c2142f
|
||||
ab2644aacf4757a51cf62e05cff6711a0a3605d60502a3dd310887df1b993545
|
27
src/json.c
27
src/json.c
@ -865,6 +865,12 @@ static void jsonParseReset(JsonParse *pParse){
|
||||
sqlite3RCStrUnref(pParse->zAlt);
|
||||
pParse->zAlt = 0;
|
||||
}
|
||||
if( pParse->nBlobAlloc ){
|
||||
sqlite3_free(pParse->aBlob);
|
||||
pParse->aBlob = 0;
|
||||
pParse->nBlob = 0;
|
||||
pParse->nBlobAlloc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4311,7 +4317,7 @@ static void jsonRemoveFromBlob(
|
||||
if( zPath==0 ) goto jsonRemoveFromBlob_patherror;
|
||||
if( zPath[0]!='$' ) goto jsonRemoveFromBlob_patherror;
|
||||
if( zPath[1]==0 ){
|
||||
if( px.nBlobAlloc ) sqlite3_free(px.aBlob);
|
||||
jsonParseReset(&px);
|
||||
return; /* return NULL if $ is removed */
|
||||
}
|
||||
px.eEdit = JEDIT_DEL;
|
||||
@ -4328,12 +4334,12 @@ static void jsonRemoveFromBlob(
|
||||
jsonStringInit(&s, ctx);
|
||||
jsonXlateBlobToText(&px, 0, &s);
|
||||
jsonReturnString(&s);
|
||||
if( px.nBlobAlloc ) sqlite3_free(px.aBlob);
|
||||
jsonParseReset(&px);
|
||||
}
|
||||
return;
|
||||
|
||||
jsonRemoveFromBlob_patherror:
|
||||
if( px.nBlobAlloc ) sqlite3_free(px.aBlob);
|
||||
jsonParseReset(&px);
|
||||
jsonPathSyntaxError(zPath, ctx);
|
||||
return;
|
||||
}
|
||||
@ -4445,14 +4451,14 @@ static void jsonInsertIntoBlob(
|
||||
break;
|
||||
}
|
||||
if( zPath[1]==0 ){
|
||||
if( px.nBlobAlloc ) sqlite3_free(px.aBlob);
|
||||
jsonParseReset(&px);
|
||||
return; /* return NULL if $ is removed */
|
||||
}
|
||||
px.eEdit = eEdit;
|
||||
px.nIns = ax.nBlob;
|
||||
px.aIns = ax.aBlob;
|
||||
rc = jsonLookupBlobStep(&px, 0, zPath+1, 0);
|
||||
if( ax.nBlobAlloc ) sqlite3_free(ax.aBlob);
|
||||
jsonParseReset(&ax);
|
||||
if( rc==JSON_BLOB_NOTFOUND ) continue;
|
||||
if( JSON_BLOB_ISERROR(rc) ) goto jsonInsertIntoBlob_patherror;
|
||||
}
|
||||
@ -4465,12 +4471,12 @@ static void jsonInsertIntoBlob(
|
||||
jsonStringInit(&s, ctx);
|
||||
jsonXlateBlobToText(&px, 0, &s);
|
||||
jsonReturnString(&s);
|
||||
if( px.nBlobAlloc ) sqlite3_free(px.aBlob);
|
||||
jsonParseReset(&px);
|
||||
}
|
||||
return;
|
||||
|
||||
jsonInsertIntoBlob_patherror:
|
||||
if( px.nBlobAlloc ) sqlite3_free(px.aBlob);
|
||||
jsonParseReset(&px);
|
||||
if( rc==JSON_BLOB_ERROR ){
|
||||
sqlite3_result_error(ctx, "malformed JSON", -1);
|
||||
}else{
|
||||
@ -4648,13 +4654,12 @@ static void jsonbFunc(
|
||||
x.nJson = nJson;
|
||||
if( jsonConvertTextToBlob(pParse, ctx) ){
|
||||
sqlite3_result_error(ctx, "malformed JSON", -1);
|
||||
sqlite3_free(pParse->aBlob);
|
||||
}else{
|
||||
sqlite3_result_blob(ctx, pParse->aBlob, pParse->nBlob, sqlite3_free);
|
||||
pParse->aBlob = 0;
|
||||
pParse->nBlob = 0;
|
||||
pParse->nBlobAlloc = 0;
|
||||
}
|
||||
pParse->aBlob = 0;
|
||||
pParse->nBlob = 0;
|
||||
pParse->nBlobAlloc = 0;
|
||||
jsonParseReset(pParse);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user