Message ID | 3e935abba1d1ea6cbf10883acf47edcb0162105c.1644404356.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | xdiff: handle allocation failures | expand |
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c index 48c5e9e3f35..b9d72f0e9f8 100644 --- a/xdiff/xmerge.c +++ b/xdiff/xmerge.c @@ -711,10 +711,18 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2, status = 0; if (!xscr1) { result->ptr = xdl_malloc(mf2->size); + if (!result->ptr) { + status = -1; + goto out; + } memcpy(result->ptr, mf2->ptr, mf2->size); result->size = mf2->size; } else if (!xscr2) { result->ptr = xdl_malloc(mf1->size); + if (!result->ptr) { + status = -1; + goto out; + } memcpy(result->ptr, mf1->ptr, mf1->size); result->size = mf1->size; } else {