Skip to content

Commit

Permalink
git-verify-pack: free pack after use and a cleanup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rene Scharfe authored and Junio C Hamano committed Aug 10, 2006
1 parent fc5fc50 commit d0d619c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions verify-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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>...";
Expand Down

0 comments on commit d0d619c

Please sign in to comment.