get_ref_dir(): return early if directory cannot be read
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
5e69491bf2
commit
d5fdae6737
13
refs.c
13
refs.c
@ -754,6 +754,9 @@ static void get_ref_dir(struct ref_cache *refs, const char *base,
|
||||
{
|
||||
DIR *d;
|
||||
const char *path;
|
||||
struct dirent *de;
|
||||
int baselen;
|
||||
char *refname;
|
||||
|
||||
if (*refs->name)
|
||||
path = git_path_submodule(refs->name, "%s", base);
|
||||
@ -761,10 +764,11 @@ static void get_ref_dir(struct ref_cache *refs, const char *base,
|
||||
path = git_path("%s", base);
|
||||
|
||||
d = opendir(path);
|
||||
if (d) {
|
||||
struct dirent *de;
|
||||
int baselen = strlen(base);
|
||||
char *refname = xmalloc(baselen + 257);
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
baselen = strlen(base);
|
||||
refname = xmalloc(baselen + 257);
|
||||
|
||||
memcpy(refname, base, baselen);
|
||||
if (baselen && base[baselen-1] != '/')
|
||||
@ -809,7 +813,6 @@ static void get_ref_dir(struct ref_cache *refs, const char *base,
|
||||
}
|
||||
free(refname);
|
||||
closedir(d);
|
||||
}
|
||||
}
|
||||
|
||||
static struct ref_dir *get_loose_refs(struct ref_cache *refs)
|
||||
|
Loading…
Reference in New Issue
Block a user