1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Detect and respond to an OOM on the jsonStringTerminate() call of

jsonReturnStringAsBlob() routine.

FossilOrigin-Name: 881f814c09b6896a448a2360b0b43dc99592ea3a1d72ac359770cbb0a2c7d38a
This commit is contained in:
drh
2024-02-07 14:05:38 +00:00
parent 8babc01892
commit 71cdea8f5f
3 changed files with 12 additions and 7 deletions

View File

@@ -1623,6 +1623,7 @@ json_parse_restart:
case '[': {
/* Parse array */
iThis = pParse->nBlob;
assert( i<=pParse->nJson );
jsonBlobAppendNode(pParse, JSONB_ARRAY, pParse->nJson - i, 0);
iStart = pParse->nBlob;
if( pParse->oom ) return -1;
@@ -2027,6 +2028,10 @@ static void jsonReturnStringAsBlob(JsonString *pStr){
JsonParse px;
memset(&px, 0, sizeof(px));
jsonStringTerminate(pStr);
if( pStr->eErr ){
sqlite3_result_error_nomem(pStr->pCtx);
return;
}
px.zJson = pStr->zBuf;
px.nJson = pStr->nUsed;
px.db = sqlite3_context_db_handle(pStr->pCtx);