summaryrefslogtreecommitdiff
path: root/server-info.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-09-13 16:19:38 -0400
committerJunio C Hamano <gitster@pobox.com>2014-09-15 11:39:54 -0700
commit3907a4078a89cffde2e2e0e61a3bd41efba96c49 (patch)
treebd5ad6621db53131f3e3362b1f5a0fe21256594b /server-info.c
parentd38379ece9216735ecc0ffd76c4c4e3da217daec (diff)
downloadgit-3907a4078a89cffde2e2e0e61a3bd41efba96c49.tar.gz
server-info: clean up after writing info/packs
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>
Diffstat (limited to 'server-info.c')
-rw-r--r--server-info.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/server-info.c b/server-info.c
index d54a3d624c..31f4a749fb 100644
--- a/server-info.c
+++ b/server-info.c
@@ -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;
@@ -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;
}