aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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;
}
}
}