diff options
author | drh <> | 2024-02-07 14:05:38 +0000 |
---|---|---|
committer | drh <> | 2024-02-07 14:05:38 +0000 |
commit | 71cdea8f5f0551e1a77a11705ad65ce4b583db2c (patch) | |
tree | 2dad5574b062f5d990ad8a39f78f81c15a88e187 /src/json.c | |
parent | 8babc0189224773fc41aed95ee603d056385908f (diff) | |
download | sqlite-71cdea8f5f0551e1a77a11705ad65ce4b583db2c.tar.gz sqlite-71cdea8f5f0551e1a77a11705ad65ce4b583db2c.zip |
Detect and respond to an OOM on the jsonStringTerminate() call of
jsonReturnStringAsBlob() routine.
FossilOrigin-Name: 881f814c09b6896a448a2360b0b43dc99592ea3a1d72ac359770cbb0a2c7d38a
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/json.c b/src/json.c index 1a4ce3af1..3aa4b4e50 100644 --- a/src/json.c +++ b/src/json.c @@ -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); |