Commit f5feadcc2d9dc4fb3f64ed21683f11df58eb73d7

Stefan Sperling 2018-06-04T16:22:01

fix bogus free() in error path of cache_pack()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/lib/pack.c b/lib/pack.c
index 6ced42c..ce51140 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -593,9 +593,10 @@ cache_pack(struct got_pack **packp, const char *path_packfile,
 	err = get_packfile_size(&pack->filesize, path_packfile);
 done:
 	if (err) {
-		if (pack)
+		if (pack) {
 			free(pack->path_packfile);
-		free(pack);
+			memset(pack, 0, sizeof(*pack));
+		}
 	} else if (packp)
 		*packp = pack;
 	return err;