Skip to content

Commit 8be707d

Browse files
sigprofJunio C Hamano
authored andcommitted
[PATCH] git-local-fetch: Fix error checking and leak in setup_indices()
setup_indices() did not check the return value of opendir(), and did not have a corresponding closedir() call. Signed-off-by: Sergey Vlasov <vsu@altlinux.ru> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent d35bbe0 commit 8be707d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

local-fetch.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ static int setup_indices(void)
3838
unsigned char sha1[20];
3939
sprintf(filename, "%s/objects/pack/", path);
4040
dir = opendir(filename);
41+
if (!dir)
42+
return -1;
4143
while ((de = readdir(dir)) != NULL) {
4244
int namelen = strlen(de->d_name);
4345
if (namelen != 50 ||
@@ -46,6 +48,7 @@ static int setup_indices(void)
4648
get_sha1_hex(de->d_name + 5, sha1);
4749
setup_index(sha1);
4850
}
51+
closedir(dir);
4952
return 0;
5053
}
5154

0 commit comments

Comments
 (0)