Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 778fb69

Browse files
committed
Merge pull request libgit2#3646 from pks-t/pks/xdiff-fix-from-upstream
xdiff: fix memleak on error case
2 parents 9b3fc89 + a4ea7fa commit 778fb69

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/xdiff/xmerge.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,11 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,
633633
result->ptr = NULL;
634634
result->size = 0;
635635

636-
if (xdl_do_diff(orig, mf1, xpp, &xe1) < 0 ||
637-
xdl_do_diff(orig, mf2, xpp, &xe2) < 0) {
636+
if (xdl_do_diff(orig, mf1, xpp, &xe1) < 0) {
637+
return -1;
638+
}
639+
if (xdl_do_diff(orig, mf2, xpp, &xe2) < 0) {
640+
xdl_free_env(&xe1);
638641
return -1;
639642
}
640643
if (xdl_change_compact(&xe1.xdf1, &xe1.xdf2, xpp->flags) < 0 ||

0 commit comments

Comments
 (0)