Skip to content

Commit f0b1f1e

Browse files
stefanbellergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1b7cb89 commit f0b1f1e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin/apply.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2776,7 +2776,8 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
27762776
default:
27772777
if (apply_verbosely)
27782778
error(_("invalid start of line: '%c'"), first);
2779-
return -1;
2779+
applied_pos = -1;
2780+
goto out;
27802781
}
27812782
if (added_blank_line) {
27822783
if (!new_blank_lines_at_end)
@@ -2915,6 +2916,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
29152916
(int)(old - oldlines), oldlines);
29162917
}
29172918

2919+
out:
29182920
free(oldlines);
29192921
strbuf_release(&newlines);
29202922
free(preimage.line_allocated);

0 commit comments

Comments
 (0)