提交 f0b1f1ec 编写于 作者: S Stefan Beller 提交者: Junio C Hamano

builtin/apply.c: fix a memleak

oldlines is allocated earlier in the function and also freed on the
successful code path.
Signed-off-by: NStefan Beller <sbeller@google.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 1b7cb896
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册