summaryrefslogtreecommitdiff
path: root/builtin/apply.c
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2015-03-20 17:28:02 -0700
committerJunio C Hamano <gitster@pobox.com>2015-03-23 11:12:58 -0700
commitf0b1f1ece71a2bcf99e5890757ee0e41490ec7e0 (patch)
tree3d5b6d5108d97c124d2506a8939cea0e111be784 /builtin/apply.c
parent1b7cb8969cb204b64b9f8ce25c86986e8144d352 (diff)
downloadgit-f0b1f1ece71a2bcf99e5890757ee0e41490ec7e0.tar.gz
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>
Diffstat (limited to 'builtin/apply.c')
-rw-r--r--builtin/apply.c4
1 files changed, 3 insertions, 1 deletions
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);