Skip to content

Commit

Permalink
Merge branch 'ps/plug-xdl-merge-leak'
Browse files Browse the repository at this point in the history
* ps/plug-xdl-merge-leak:
  xdiff/xmerge: fix memory leak in xdl_merge
  • Loading branch information
Junio C Hamano committed Feb 26, 2016
2 parents 1e4c08f + 4867f11 commit c1fa85f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions xdiff/xmerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,11 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,
result->ptr = NULL;
result->size = 0;

if (xdl_do_diff(orig, mf1, xpp, &xe1) < 0 ||
xdl_do_diff(orig, mf2, xpp, &xe2) < 0) {
if (xdl_do_diff(orig, mf1, xpp, &xe1) < 0) {
return -1;
}
if (xdl_do_diff(orig, mf2, xpp, &xe2) < 0) {
xdl_free_env(&xe1);
return -1;
}
if (xdl_change_compact(&xe1.xdf1, &xe1.xdf2, xpp->flags) < 0 ||
Expand All @@ -654,6 +657,8 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,
if (xdl_change_compact(&xe2.xdf1, &xe2.xdf2, xpp->flags) < 0 ||
xdl_change_compact(&xe2.xdf2, &xe2.xdf1, xpp->flags) < 0 ||
xdl_build_script(&xe2, &xscr2) < 0) {
xdl_free_script(xscr1);
xdl_free_env(&xe1);
xdl_free_env(&xe2);
return -1;
}
Expand Down

0 comments on commit c1fa85f

Please sign in to comment.