lib/package_unpack.c: fix two possible memleaks.

This commit is contained in:
Juan RP 2013-04-04 09:55:35 +02:00
parent e29f2216e2
commit c753eae9f7

View File

@ -191,7 +191,6 @@ unpack_archive(struct xbps_handle *xhp,
if (archive_read_data(ar, instbuf, entry_size) != if (archive_read_data(ar, instbuf, entry_size) !=
entry_size) { entry_size) {
rv = EINVAL; rv = EINVAL;
free(instbuf);
goto out; goto out;
} }
@ -204,7 +203,6 @@ unpack_archive(struct xbps_handle *xhp,
"%s: [unpack] INSTALL script failed " "%s: [unpack] INSTALL script failed "
"to execute pre ACTION: %s", "to execute pre ACTION: %s",
pkgver, strerror(rv)); pkgver, strerror(rv));
free(instbuf);
goto out; goto out;
} }
continue; continue;
@ -217,7 +215,6 @@ unpack_archive(struct xbps_handle *xhp,
if (archive_read_data(ar, rembuf, entry_size) != if (archive_read_data(ar, rembuf, entry_size) !=
entry_size) { entry_size) {
rv = EINVAL; rv = EINVAL;
free(rembuf);
goto out; goto out;
} }
continue; continue;
@ -258,11 +255,6 @@ unpack_archive(struct xbps_handle *xhp,
XBPS_STATE_UNPACK_FAIL, ENODEV, pkgver, XBPS_STATE_UNPACK_FAIL, ENODEV, pkgver,
"%s: [unpack] invalid binary package `%s'.", "%s: [unpack] invalid binary package `%s'.",
pkgver, fname); pkgver, fname);
if (instbuf != NULL)
free(instbuf);
if (rembuf != NULL)
free(rembuf);
rv = ENODEV; rv = ENODEV;
goto out; goto out;
} }
@ -539,14 +531,12 @@ out1:
assert(data); assert(data);
prop_dictionary_set(pkg_metad, "install-script", data); prop_dictionary_set(pkg_metad, "install-script", data);
prop_object_release(data); prop_object_release(data);
free(instbuf);
} }
if (rembuf != NULL) { if (rembuf != NULL) {
data = prop_data_create_data(rembuf, rembufsiz); data = prop_data_create_data(rembuf, rembufsiz);
assert(data); assert(data);
prop_dictionary_set(pkg_metad, "remove-script", data); prop_dictionary_set(pkg_metad, "remove-script", data);
prop_object_release(data); prop_object_release(data);
free(rembuf);
} }
/* Remove unneeded objs from transaction */ /* Remove unneeded objs from transaction */
prop_dictionary_remove(pkg_metad, "remove-and-update"); prop_dictionary_remove(pkg_metad, "remove-and-update");
@ -586,6 +576,10 @@ out:
prop_object_release(propsd); prop_object_release(propsd);
if (pkgname != NULL) if (pkgname != NULL)
free(pkgname); free(pkgname);
if (instbuf != NULL)
free(instbuf);
if (rembuf != NULL)
free(rembuf);
return rv; return rv;
} }