[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>
Sergey Vlasov committed
Sep 23, 2005 at 16:28 UTC
8be707de55e473a5d850a1fcdc6e30589a37d548
1 file changed
+3
local-fetch.c
+3
@@ -38,6 +38,8 @@ static int setup_indices(void)
38
unsigned char sha1[20];
39
sprintf(filename, "%s/objects/pack/", path);
40
dir = opendir(filename);
41
+ if (!dir)
42
+ return -1;
43
while ((de = readdir(dir)) != NULL) {
44
int namelen = strlen(de->d_name);
45
if (namelen != 50 ||
@@ -46,6 +48,7 @@ static int setup_indices(void)
48
get_sha1_hex(de->d_name + 5, sha1);
49
setup_index(sha1);
50
}
51
+ closedir(dir);
52
return 0;
53
}
54