mirror of
https://github.com/sqlite/sqlite.git
synced 2026-01-06 08:01:16 +03:00
Fix jsonForceRCStr() to also add the NULL terminator.
FossilOrigin-Name: 134b01f37f8f741d7f7b7eda81384695d1cbe4c39751d87f08832d5c9afdcef2
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
||||
C Merge\sthe\slatest\strunk\sfixes\sinto\sthe\sjson-opt\sbranch.
|
||||
D 2023-07-26T01:15:34.571
|
||||
C Fix\sjsonForceRCStr()\sto\salso\sadd\sthe\sNULL\sterminator.
|
||||
D 2023-07-26T11:00:47.983
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@@ -598,7 +598,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 790ca70b1f8884610fe5401ac6f260d955d47d9c14c9f3d2aa6541fd881faf07
|
||||
F src/json.c b3f20f01dc6e11071b0b5a8fda73a16c23fd7e65356ec715c0082e904f3fb284
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c 176d6b2cb18a6ad73b133db17f6fc351c4d9a2d510deebdb76c22bde9cfd1465
|
||||
F src/main.c 512b1d45bc556edf4471a845afb7ba79e64bd5b832ab222dc195c469534cd002
|
||||
@@ -2044,8 +2044,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 a4c1af616e672a0d4d04f2652e645617758231598fb7161b956883512303ae87 54b3c43fdfdaca6b129a5f0ee93c34eb001663775d33c087066650f5e164d1c1
|
||||
R 31a2d8c82324ae8c8feb0c4037e19a24
|
||||
P ef4e1664d159b98854d9aa580b0bb942f1726f32a190e2ea659c171131ddce9a
|
||||
R d6f55ea1e7a815bfa0f96bc129102acf
|
||||
U drh
|
||||
Z df17bf2cf88062fccaa06a3f8068b84c
|
||||
Z d5c0e742c545064eb8b7fe7e17a2bad7
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
||||
@@ -1 +1 @@
|
||||
ef4e1664d159b98854d9aa580b0bb942f1726f32a190e2ea659c171131ddce9a
|
||||
134b01f37f8f741d7f7b7eda81384695d1cbe4c39751d87f08832d5c9afdcef2
|
||||
28
src/json.c
28
src/json.c
@@ -248,16 +248,6 @@ static int jsonGrow(JsonString *p, u32 N){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/* Try to force the string to be an RCStr string, rather than a
|
||||
** static string. Return true on success. The only reason this
|
||||
** might fail is due to an OOM fault.
|
||||
*/
|
||||
static int jsonForceRCStr(JsonString *p){
|
||||
if( p->bStatic==0 ) return 1;
|
||||
jsonGrow(p, p->nAlloc+1);
|
||||
return p->bStatic==0;
|
||||
}
|
||||
|
||||
/* Append N bytes from zIn onto the end of the JsonString string.
|
||||
*/
|
||||
static SQLITE_NOINLINE void jsonAppendExpand(
|
||||
@@ -315,6 +305,22 @@ static void jsonAppendChar(JsonString *p, char c){
|
||||
}
|
||||
}
|
||||
|
||||
/* Try to force the string to be a zero-terminated RCStr string.
|
||||
**
|
||||
** Return true on success. Return false if an OOM prevents this
|
||||
** from happening.
|
||||
*/
|
||||
static int jsonForceRCStr(JsonString *p){
|
||||
jsonAppendChar(p, 0);
|
||||
if( p->bErr ) return 0;
|
||||
p->nUsed--;
|
||||
if( p->bStatic==0 ) return 1;
|
||||
p->nAlloc = 0;
|
||||
jsonGrow(p, p->nUsed);
|
||||
return p->bStatic==0;
|
||||
}
|
||||
|
||||
|
||||
/* Append a comma separator to the output buffer, if the previous
|
||||
** character is not '[' or '{'.
|
||||
*/
|
||||
@@ -798,8 +804,6 @@ static void jsonReturnJson(
|
||||
jsonInit(&s, pCtx);
|
||||
jsonRenderNode(pParse, pNode, &s);
|
||||
if( bGenerateAlt && pParse->zAlt==0 && jsonForceRCStr(&s) ){
|
||||
jsonAppendChar(&s, 0);
|
||||
s.nUsed--;
|
||||
pParse->zAlt = sqlite3RCStrRef(s.zBuf);
|
||||
pParse->nAlt = s.nUsed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user