Commit 613381fc1461514fdbb1518799bcee0345fdece6

Patrick Steinhardt 2016-11-15T13:33:05

patch_parse: fix memory leak

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/patch_parse.c b/src/patch_parse.c
index 7a4fe9f..f527594 100644
--- a/src/patch_parse.c
+++ b/src/patch_parse.c
@@ -1014,8 +1014,10 @@ git_patch_parse_ctx *git_patch_parse_ctx_init(
 		return NULL;
 
 	if (content_len) {
-		if ((ctx->content = git__malloc(content_len)) == NULL)
+		if ((ctx->content = git__malloc(content_len)) == NULL) {
+			git__free(ctx);
 			return NULL;
+		}
 
 		memcpy((char *)ctx->content, content, content_len);
 	}