Skip to content

Commit

Permalink
server-info: clean up after writing info/packs
Browse files Browse the repository at this point in the history
We allocate pack information in a static global list but
never clean it up. This leaks memory, and means that calling
update_server_info twice will generate a buggy file (it will
have duplicate entries).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Sep 15, 2014
1 parent d38379e commit 3907a40
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ static void init_pack_info(const char *infofile, int force)
info[i]->new_num = i;
}

static void free_pack_info(void)
{
int i;
for (i = 0; i < num_pack; i++)
free(info[i]);
free(info);
}

static int write_pack_info_file(FILE *fp)
{
int i;
Expand All @@ -252,6 +260,7 @@ static int update_info_packs(int force)

init_pack_info(infofile, force);
ret = update_info_file(infofile, write_pack_info_file);
free_pack_info();
free(infofile);
return ret;
}
Expand Down

0 comments on commit 3907a40

Please sign in to comment.