fix bogus free() in error path of cache_pack()
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;