summaryrefslogtreecommitdiff
path: root/verify-pack.c
diff options
context:
space:
mode:
authorRene Scharfe <rene.scharfe@lsrfire.ath.cx>2006-08-10 15:02:35 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-08-10 21:15:49 (GMT)
commitd0d619c8c50b90fbbd6a7e0994fde073341bf92b (patch)
treee1a8bc48c14c92eea7f2bf7dc2d62c29c3c1681f /verify-pack.c
parentfc5fc50980958f742a9f3d79fb7a64f02e87877a (diff)
downloadgit-d0d619c8c50b90fbbd6a7e0994fde073341bf92b.zip
git-d0d619c8c50b90fbbd6a7e0994fde073341bf92b.tar.gz
git-d0d619c8c50b90fbbd6a7e0994fde073341bf92b.tar.bz2
git-verify-pack: free pack after use and a cleanup
Plug memory leak in verify_one_pack() by freeing the struct packed_git we got from add_packed_git(). Also rename g to pack and pull an assignment out of an if statement while we're at it. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'verify-pack.c')
-rw-r--r--verify-pack.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/verify-pack.c b/verify-pack.c
index c729314..78d789c 100644
--- a/verify-pack.c
+++ b/verify-pack.c
@@ -5,7 +5,8 @@ static int verify_one_pack(const char *path, int verbose)
{
char arg[PATH_MAX];
int len;
- struct packed_git *g;
+ struct packed_git *pack;
+ int err;
len = strlcpy(arg, path, PATH_MAX);
if (len >= PATH_MAX)
@@ -25,10 +26,14 @@ static int verify_one_pack(const char *path, int verbose)
len += 4;
}
- if (!(g = add_packed_git(arg, len, 1)))
+ pack = add_packed_git(arg, len, 1);
+ if (!pack)
return error("packfile %s not found.", arg);
- return verify_pack(g, verbose);
+ err = verify_pack(pack, verbose);
+ free(pack);
+
+ return err;
}
static const char verify_pack_usage[] = "git-verify-pack [-v] <pack>...";