Commit 3fe5768b061f319a4f8fa55c25614a31767d2208

Patrick Steinhardt 2016-03-01T17:55:40

pack-objects: fix memory leak on overflow

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 46fe8f3..11e13f7 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -848,8 +848,10 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
 
 		git_packbuilder__cache_unlock(pb);
 
-		if (overflow)
+		if (overflow) {
+			git__free(delta_buf);
 			return -1;
+		}
 
 		trg_object->delta_data = git__realloc(delta_buf, delta_size);
 		GITERR_CHECK_ALLOC(trg_object->delta_data);