commit - c9e76cc42e880db2e858c1e99942214157bd7ea9
commit + c3821befbed0b67d1b48a5cfa3aaa2e022c58430
blob - de71b5845e334bff8e56366f910514f149cf3519
blob + 78eb9ebab2c20cab529d7f47d39f8d4829ac8699
--- lib/reference.c
+++ lib/reference.c
const char *refname, int lock)
{
const struct got_error *err = NULL;
- char *path_refs = NULL;
+ char *packed_refs_path = NULL, *path_refs = NULL;
const char *subdirs[] = {
GOT_REF_HEADS, GOT_REF_TAGS, GOT_REF_REMOTES
};
if (well_known) {
err = open_ref(ref, path_refs, "", refname, lock);
} else {
- char *packed_refs_path;
FILE *f;
/* Search on-disk refs before packed refs! */
goto done;
}
f = fopen(packed_refs_path, "rbe");
- free(packed_refs_path);
if (f != NULL) {
struct stat sb;
if (fstat(fileno(f), &sb) == -1) {
err = got_error_not_ref(refname);
if (err && lf)
got_lockfile_unlock(lf, -1);
+ free(packed_refs_path);
free(path_refs);
return err;
}
const char *ref_namespace, got_ref_cmp_cb cmp_cb, void *cmp_arg)
{
const struct got_error *err;
- char *packed_refs_path, *path_refs = NULL;
+ char *packed_refs_path = NULL, *path_refs = NULL;
char *abs_namespace = NULL, *buf = NULL;
const char *ondisk_ref_namespace = NULL;
char *line = NULL;
}
f = fopen(packed_refs_path, "re");
- free(packed_refs_path);
if (f) {
size_t linesize = 0;
ssize_t linelen;
}
}
done:
+ free(packed_refs_path);
free(abs_namespace);
free(buf);
free(line);