Skip to content

Commit 3623252

Browse files
committed
refdb_fs: Check git_sortedcache wlock/rlock errors
To prevent a race condition, these wlock/rlock calls should probably be checked for errors.
1 parent 935f851 commit 3623252

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/refdb_fs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
254254
if ((error = loose_parse_oid(&oid, name, &ref_file)) < 0)
255255
goto done;
256256

257-
git_sortedcache_wlock(backend->refcache);
257+
if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
258+
goto done;
258259

259260
if (!(error = git_sortedcache_upsert(
260261
(void **)&ref, backend->refcache, name))) {
@@ -760,7 +761,8 @@ static int reference_path_available(
760761
}
761762
}
762763

763-
git_sortedcache_rlock(backend->refcache);
764+
if ((error = git_sortedcache_rlock(backend->refcache)) < 0)
765+
return error;
764766

765767
for (i = 0; i < git_sortedcache_entrycount(backend->refcache); ++i) {
766768
struct packref *ref = git_sortedcache_entry(backend->refcache, i);

0 commit comments

Comments
 (0)