Commit 043a87a0aaae203537e069af9f2599c18a9732a5

Edward Thomson 2022-02-27T09:21:53

refdb: unlock mutex on assertion failure If we're safely asserting (and returning an error to the caller), we should still unlock our mutex.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/libgit2/refdb_fs.c b/src/libgit2/refdb_fs.c
index 95bda94..ef85016 100644
--- a/src/libgit2/refdb_fs.c
+++ b/src/libgit2/refdb_fs.c
@@ -1361,7 +1361,11 @@ static int packed_write(refdb_fs_backend *backend)
 
 	for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) {
 		struct packref *ref = git_sortedcache_entry(refcache, i);
-		GIT_ASSERT(ref);
+
+		GIT_ASSERT_WITH_CLEANUP(ref, {
+			error = -1;
+			goto fail;
+		});
 
 		if ((error = packed_find_peel(backend, ref)) < 0)
 			goto fail;