From: Phillip Wood <phillip.wood@xxxxxxxxxxxxx> Other users of xdiff such as libgit2 need to be able to handle allocation failures. These allocation failures were previously ignored. Signed-off-by: Phillip Wood <phillip.wood@xxxxxxxxxxxxx> --- xdiff/xmerge.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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 { -- gitgitgadget