Commit 1f44079cae42864cb51d98ca57f5d1f4d8296693

Edward Thomson 2019-07-20T18:08:40

Merge pull request #5179 from pks-t/pks/patch-parse-free patch_parse: fix segfault due to line containing static contents

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/patch_parse.c b/src/patch_parse.c
index 70c33ed..29dc8b8 100644
--- a/src/patch_parse.c
+++ b/src/patch_parse.c
@@ -653,7 +653,7 @@ static int parse_hunk_body(
 
 		memset(line, 0x0, sizeof(git_diff_line));
 
-		line->content = ctx->parse_ctx.line;
+		line->content = git__strdup(ctx->parse_ctx.line);
 		line->content_len = ctx->parse_ctx.line_len;
 		line->content_offset = ctx->parse_ctx.content_len - ctx->parse_ctx.remain_len;
 		line->origin = eof_for_origin(last_origin);