aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2023-11-28 13:35:53 +0000
committerdrh <>2023-11-28 13:35:53 +0000
commitec1f59f0cdf988c2b4d66d0c8662832a64a60dfa (patch)
tree3db1af28a7129fa98334355cc950af5590addb25 /src
parent5026ddb83d04aeca4f4ec487c572e27b2c87d6b7 (diff)
downloadsqlite-ec1f59f0cdf988c2b4d66d0c8662832a64a60dfa.tar.gz
sqlite-ec1f59f0cdf988c2b4d66d0c8662832a64a60dfa.zip
All legacy tests are passing.
FossilOrigin-Name: 2c436806b8d5f57de99c00f6154b038454fb9ae427d00d7b4a46ab9c7c69bcb9
Diffstat (limited to 'src')
-rw-r--r--src/json.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/json.c b/src/json.c
index 6f5021aaf..bdc908732 100644
--- a/src/json.c
+++ b/src/json.c
@@ -5177,24 +5177,32 @@ static int jsonMergePatchBlob(
if( pTarget->oom ) return JSON_MERGE_OOM;
}else{
/* Algorithm line 12 */
- int rc = jsonMergePatchBlob(pTarget, iTValue, pPatch, iPValue);
+ int rc, savedDelta = pTarget->delta;
+ pTarget->delta = 0;
+ rc = jsonMergePatchBlob(pTarget, iTValue, pPatch, iPValue);
if( rc ) return rc;
+ pTarget->delta += savedDelta;
}
}else if( x>0 ){ /* Algorithm line 13 */
/* No match and patch value is not NULL */
+ u32 szNew = szPLabel+nPLabel;
if( (pPatch->aBlob[iPValue] & 0x0f)!=JSONB_OBJECT ){ /* Line 14 */
- jsonBlobEdit(pTarget, iTEnd, 0,
- pPatch->aBlob+iPValue, szPValue+nPValue);
+ jsonBlobEdit(pTarget, iTEnd, 0, 0, szPValue+nPValue+szNew);
if( pTarget->oom ) return JSON_MERGE_OOM;
+ memcpy(&pTarget->aBlob[iTEnd], &pPatch->aBlob[iPLabel], szNew);
+ memcpy(&pTarget->aBlob[iTEnd+szNew],
+ &pPatch->aBlob[iPValue], szPValue+nPValue);
}else{
- int rc;
- u32 szNew = szPLabel+nPLabel;
+ int rc, savedDelta;
jsonBlobEdit(pTarget, iTEnd, 0, 0, szNew+1);
if( pTarget->oom ) return JSON_MERGE_OOM;
memcpy(&pTarget->aBlob[iTEnd], &pPatch->aBlob[iPLabel], szNew);
pTarget->aBlob[iTEnd+szNew] = 0x00;
+ savedDelta = pTarget->delta;
+ pTarget->delta = 0;
rc = jsonMergePatchBlob(pTarget, iTEnd+szNew,pPatch,iPValue);
if( rc ) return rc;
+ pTarget->delta += savedDelta;
}
}
}