From: Stefan Beller Date: Sat, 21 Mar 2015 00:28:02 +0000 (-0700) Subject: builtin/apply.c: fix a memleak X-Git-Tag: v2.4.0-rc1~9^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f0b1f1ece71a2bcf99e5890757ee0e41490ec7e0;p=thirdparty%2Fgit.git builtin/apply.c: fix a memleak oldlines is allocated earlier in the function and also freed on the successful code path. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- diff --git a/builtin/apply.c b/builtin/apply.c index 65b97eee69..0769b09287 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -2776,7 +2776,8 @@ static int apply_one_fragment(struct image *img, struct fragment *frag, default: if (apply_verbosely) error(_("invalid start of line: '%c'"), first); - return -1; + applied_pos = -1; + goto out; } if (added_blank_line) { if (!new_blank_lines_at_end) @@ -2915,6 +2916,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag, (int)(old - oldlines), oldlines); } +out: free(oldlines); strbuf_release(&newlines); free(preimage.line_allocated);