From c753eae9f7d013f9a6aac1521330c4df49fc4e9f Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 4 Apr 2013 09:55:35 +0200 Subject: [PATCH] lib/package_unpack.c: fix two possible memleaks. --- lib/package_unpack.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/package_unpack.c b/lib/package_unpack.c index bcd1dc70..bdaed7c3 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -191,7 +191,6 @@ unpack_archive(struct xbps_handle *xhp, if (archive_read_data(ar, instbuf, entry_size) != entry_size) { rv = EINVAL; - free(instbuf); goto out; } @@ -204,7 +203,6 @@ unpack_archive(struct xbps_handle *xhp, "%s: [unpack] INSTALL script failed " "to execute pre ACTION: %s", pkgver, strerror(rv)); - free(instbuf); goto out; } continue; @@ -217,7 +215,6 @@ unpack_archive(struct xbps_handle *xhp, if (archive_read_data(ar, rembuf, entry_size) != entry_size) { rv = EINVAL; - free(rembuf); goto out; } continue; @@ -258,11 +255,6 @@ unpack_archive(struct xbps_handle *xhp, XBPS_STATE_UNPACK_FAIL, ENODEV, pkgver, "%s: [unpack] invalid binary package `%s'.", pkgver, fname); - if (instbuf != NULL) - free(instbuf); - if (rembuf != NULL) - free(rembuf); - rv = ENODEV; goto out; } @@ -539,14 +531,12 @@ out1: assert(data); prop_dictionary_set(pkg_metad, "install-script", data); prop_object_release(data); - free(instbuf); } if (rembuf != NULL) { data = prop_data_create_data(rembuf, rembufsiz); assert(data); prop_dictionary_set(pkg_metad, "remove-script", data); prop_object_release(data); - free(rembuf); } /* Remove unneeded objs from transaction */ prop_dictionary_remove(pkg_metad, "remove-and-update"); @@ -586,6 +576,10 @@ out: prop_object_release(propsd); if (pkgname != NULL) free(pkgname); + if (instbuf != NULL) + free(instbuf); + if (rembuf != NULL) + free(rembuf); return rv; }