diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2022-02-16 10:15:09 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-02-16 10:58:16 -0800 |
commit | 43ad3af380702d9e304140f259480de59320e587 (patch) | |
tree | 157c8f9dcf5f4dda0d8985430310865116f3143c /xdiff/xmerge.c | |
parent | 4a37b80e88f8f26a2f56d77c5ad6caa41d572ea8 (diff) | |
download | git-43ad3af380702d9e304140f259480de59320e587.tar.gz |
xdiff: handle allocation failure when merging
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@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'xdiff/xmerge.c')
-rw-r--r-- | xdiff/xmerge.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c index d43abe05b9..af40c88a5b 100644 --- a/xdiff/xmerge.c +++ b/xdiff/xmerge.c @@ -708,13 +708,18 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2, xdl_build_script(&xe2, &xscr2) < 0) goto out; - status = 0; if (!xscr1) { result->ptr = xdl_malloc(mf2->size); + if (!result->ptr) + goto out; + status = 0; memcpy(result->ptr, mf2->ptr, mf2->size); result->size = mf2->size; } else if (!xscr2) { result->ptr = xdl_malloc(mf1->size); + if (!result->ptr) + goto out; + status = 0; memcpy(result->ptr, mf1->ptr, mf1->size); result->size = mf1->size; } else { |