From d5f9366bfcd5461e3c8a0763cadf72654a68daef Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 18 Nov 2009 07:17:45 +0100 Subject: [PATCH] xbps-repo: fix previous, writing a dangling string and a leak in exit path. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091118061745-xirdogil114siw2c --- bin/xbps-repo/index.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/bin/xbps-repo/index.c b/bin/xbps-repo/index.c index cef87d98..32e3fa01 100644 --- a/bin/xbps-repo/index.c +++ b/bin/xbps-repo/index.c @@ -112,12 +112,6 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *file) goto out1; } - /* Get package array in repo index file */ - pkgar = prop_dictionary_get(idxdict, "packages"); - if (pkgar == NULL) { - rv = errno; - goto out1; - } /* * Open the binary package and read the props.plist * into a buffer. @@ -173,7 +167,7 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *file) * We have the dictionary now, add the required * objects for the index. */ - prop_dictionary_set_cstring_nocopy(newpkgd, "filename", filen); + prop_dictionary_set_cstring(newpkgd, "filename", filen); sha256 = xbps_get_file_hash(file); if (sha256 == NULL) { prop_object_release(newpkgd); @@ -193,6 +187,13 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *file) /* * Add dictionary into the index and update package count. */ + /* Get package array in repo index file */ + pkgar = prop_dictionary_get(idxdict, "packages"); + if (pkgar == NULL) { + prop_object_release(newpkgd); + rv = errno; + break; + } if (!xbps_add_obj_to_array(pkgar, newpkgd)) { prop_object_release(newpkgd); rv = EINVAL; @@ -320,6 +321,8 @@ xbps_repo_genindex(const char *pkgdir) if (!prop_dictionary_externalize_to_file(idxdict, plist)) rv = errno; } + free(plist); + prop_object_release(idxdict); return rv; }