Skip to content

Commit

Permalink
builtin/apply.c: fix a memleak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stefan Beller authored and Junio C Hamano committed Mar 23, 2015
1 parent 1b7cb89 commit f0b1f1e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion builtin/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f0b1f1e

Please sign in to comment.