mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Fix a missing zero-terminator on a string when processing
JSON aggregates into JSONB. FossilOrigin-Name: fb81d570a3d9b8f55e9f278d5240605c5d0f3c5abde51550797999d03cf193a7
This commit is contained in:
@@ -486,6 +486,14 @@ static void jsonAppendChar(JsonString *p, char c){
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure there is a zero terminator on p->zBuf[]
|
||||
*/
|
||||
static void jsonStringTerminate(JsonString *p){
|
||||
if( p->nUsed<p->nAlloc || jsonStringGrow(p,1) ){
|
||||
p->zBuf[p->nUsed] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Try to force the string to be a zero-terminated RCStr string.
|
||||
**
|
||||
** Return true on success. Return false if an OOM prevents this
|
||||
@@ -3210,6 +3218,7 @@ static int jsonConvertTextToBlob(
|
||||
static void jsonReturnStringAsBlob(JsonString *pStr){
|
||||
JsonParse px;
|
||||
memset(&px, 0, sizeof(px));
|
||||
jsonStringTerminate(pStr);
|
||||
px.zJson = pStr->zBuf;
|
||||
px.nJson = pStr->nUsed;
|
||||
(void)jsonXlateTextToBlob(&px, 0);
|
||||
|
||||
Reference in New Issue
Block a user