mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Improved handling of OOM while translating the JsonNode representing into
the BLOB representation. FossilOrigin-Name: ef5956710bb542d6045c82937d02218a7ed45af94cf3959b0c180268e04d14e1
This commit is contained in:
14
src/json.c
14
src/json.c
@@ -1011,7 +1011,12 @@ static void jsonReturnNodeAsJson(
|
||||
JsonParse x;
|
||||
memset(&x, 0, sizeof(x));
|
||||
jsonRenderNodeAsBlob(pParse, pNode, &x);
|
||||
sqlite3_result_blob(pCtx, x.aBlob, x.nBlob, sqlite3_free);
|
||||
if( x.oom ){
|
||||
sqlite3_result_error_nomem(pCtx);
|
||||
sqlite3_free(x.aBlob);
|
||||
}else{
|
||||
sqlite3_result_blob(pCtx, x.aBlob, x.nBlob, sqlite3_free);
|
||||
}
|
||||
}else{
|
||||
jsonStringInit(&s, pCtx);
|
||||
jsonRenderNodeAsText(pParse, pNode, &s);
|
||||
@@ -2598,8 +2603,11 @@ static void jsonBlobChangePayloadSize(
|
||||
u32 i,
|
||||
u32 szPayload
|
||||
){
|
||||
u8 *a = &pParse->aBlob[i];
|
||||
u8 szType = a[0]>>4;
|
||||
u8 *a;
|
||||
u8 szType;
|
||||
if( pParse->oom ) return;
|
||||
a = &pParse->aBlob[i];
|
||||
szType = a[0]>>4;
|
||||
if( szType<=11 ){
|
||||
assert( szPayload<=11 );
|
||||
a[0] = (a[0] & 0x0f) | (szPayload<<4);
|
||||
|
||||
Reference in New Issue
Block a user