[PATCH 3/3] server-info: clean up after writing info/packs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
 server-info.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/server-info.c b/server-info.c
index d54a3d6..31f4a74 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;
 }
-- 
2.1.0.373.g91ca799
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]