xbps-repo: fix previous, writing a dangling string and a leak in exit path.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20091118061745-xirdogil114siw2c
This commit is contained in:
Juan RP 2009-11-18 07:17:45 +01:00
parent f859663a4b
commit d5f9366bfc

View File

@ -112,12 +112,6 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *file)
goto out1; 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 * Open the binary package and read the props.plist
* into a buffer. * 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 * We have the dictionary now, add the required
* objects for the index. * 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); sha256 = xbps_get_file_hash(file);
if (sha256 == NULL) { if (sha256 == NULL) {
prop_object_release(newpkgd); 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. * 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)) { if (!xbps_add_obj_to_array(pkgar, newpkgd)) {
prop_object_release(newpkgd); prop_object_release(newpkgd);
rv = EINVAL; rv = EINVAL;
@ -320,6 +321,8 @@ xbps_repo_genindex(const char *pkgdir)
if (!prop_dictionary_externalize_to_file(idxdict, plist)) if (!prop_dictionary_externalize_to_file(idxdict, plist))
rv = errno; rv = errno;
} }
free(plist);
prop_object_release(idxdict);
return rv; return rv;
} }