diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-02-26 13:37:22 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-02-26 13:37:22 -0800 |
commit | c1fa85ff8ceae0e882d19b1548de407994ee4180 (patch) | |
tree | f292383fd2073b0d2315411471b10163fc396523 /xdiff | |
parent | 1e4c08ff7e0f1d17b4a8e2c04edca8fc00455881 (diff) | |
parent | 4867f1184c943f7738bb7b42cab2e62cf16cdb18 (diff) | |
download | git-c1fa85ff8ceae0e882d19b1548de407994ee4180.tar.gz git-c1fa85ff8ceae0e882d19b1548de407994ee4180.tar.xz |
Merge branch 'ps/plug-xdl-merge-leak'
* ps/plug-xdl-merge-leak:
xdiff/xmerge: fix memory leak in xdl_merge
Diffstat (limited to 'xdiff')
-rw-r--r-- | xdiff/xmerge.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c index d98f430c9..f338ad6c7 100644 --- a/xdiff/xmerge.c +++ b/xdiff/xmerge.c @@ -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 || @@ -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; } |