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 <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Mar 20, 2015 at 17:28 UTC
f0b1f1ece71a2bcf99e5890757ee0e41490ec7e0
1 file changed
+3
-1
builtin/apply.c
+3
-1
@@ -2776,7 +2776,8 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
2776
default:
2777
if (apply_verbosely)
2778
error(_("invalid start of line: '%c'"), first);
2779
- return -1;
2779
+ applied_pos = -1;
2780
+ goto out;
2781
}
2782
if (added_blank_line) {
2783
if (!new_blank_lines_at_end)
@@ -2915,6 +2916,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
2916
(int)(old - oldlines), oldlines);
2917
}
2918
2919
+out:
2920
free(oldlines);
2921
strbuf_release(&newlines);
2922
free(preimage.line_allocated);