diff options
author | drh <> | 2023-10-03 22:40:22 +0000 |
---|---|---|
committer | drh <> | 2023-10-03 22:40:22 +0000 |
commit | 4500d87e763914432dd65d181e2bbe928a36500b (patch) | |
tree | cddd37a47684738c990e0233e5feb81e7f995143 /src | |
parent | f362731c1cba8f46cba7b978705573d9e0a1eb51 (diff) | |
download | sqlite-4500d87e763914432dd65d181e2bbe928a36500b.tar.gz sqlite-4500d87e763914432dd65d181e2bbe928a36500b.zip |
Fix a memory leak in JSON group-aggregates when the output is JSONB.
FossilOrigin-Name: 08e7db138b636890cb29a76d65c2069c6e2ff44470fa4bca14f4526fe5f195ae
Diffstat (limited to 'src')
-rw-r--r-- | src/json.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/json.c b/src/json.c index e29940c72..955c35377 100644 --- a/src/json.c +++ b/src/json.c @@ -4905,7 +4905,11 @@ static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){ assert( pStr->bStatic ); }else if( flags & JSON_BLOB ){ jsonReturnStringAsBlob(pStr); - if( !isFinal ) pStr->nUsed--; + if( isFinal ){ + sqlite3RCStrUnref(pStr->zBuf); + }else{ + pStr->nUsed--; + } return; }else if( isFinal ){ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, @@ -5021,7 +5025,11 @@ static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){ assert( pStr->bStatic ); }else if( flags & JSON_BLOB ){ jsonReturnStringAsBlob(pStr); - if( !isFinal ) pStr->nUsed--; + if( isFinal ){ + sqlite3RCStrUnref(pStr->zBuf); + }else{ + pStr->nUsed--; + } return; }else if( isFinal ){ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, |