Commit 903955f7e5d81e12ef806636c7c5fbfd6203266c

Carlos Martín Nieto 2016-12-19T17:26:09

Merge pull request #4027 from pks-t/pks/pack-deref-cache-on-error pack: dereference cached pack entry on error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/pack.c b/src/pack.c
index 56de64d..2e19b3b 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -759,8 +759,11 @@ int git_packfile_unpack(
 	}
 
 cleanup:
-	if (error < 0)
+	if (error < 0) {
 		git__free(obj->data);
+		if (cached)
+			git_atomic_dec(&cached->refcount);
+	}
 
 	if (elem)
 		*obj_offset = curpos;