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

Skip to content

Commit a4ea7fa

Browse files
committed
xdiff: fix memleak on error case
Commit 3d1abc5 fixes a memory leak in the xdiff code. In the process of upstreaming the fix it was pointed out by Johannes Schindelin that there is another memory leak present (see [1]). Fix the second memory leak by applying the upstream fix to our code base. [1]: http://thread.gmane.org/gmane.comp.version-control.git/287034
1 parent dbee683 commit a4ea7fa

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)