Commit b0014063b229132b358e56b40892807d1ee5df9d

Etienne Samson 2016-12-26T22:13:35

patch: memory leak of patch.base.diff_opts.new|old_prefix

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/patch_generate.c b/src/patch_generate.c
index 3559cc2..ab68f58 100644
--- a/src/patch_generate.c
+++ b/src/patch_generate.c
@@ -451,8 +451,10 @@ int git_diff_foreach(
 
 		if (binary_cb || hunk_cb || data_cb) {
 			if ((error = patch_generated_init(&patch, diff, idx)) != 0 ||
-				(error = patch_generated_load(&patch, &xo.output)) != 0)
+				(error = patch_generated_load(&patch, &xo.output)) != 0) {
+				git_patch_free(&patch.base);
 				return error;
+			}
 		}
 
 		if ((error = patch_generated_invoke_file_callback(&patch, &xo.output)) == 0) {