xbps-pkgdb: fixed some memleaks.

This commit is contained in:
Juan RP 2012-12-14 06:04:58 +01:00
parent a0443fc4ce
commit 338c0d549f
3 changed files with 12 additions and 2 deletions

View File

@ -139,7 +139,9 @@ check_pkg_integrity(struct xbps_handle *xhp,
/* /*
* Check for props.plist metadata file. * Check for props.plist metadata file.
*/ */
propsd = xbps_pkgdb_get_pkg_metadata(xhp, pkgname); buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
propsd = prop_dictionary_internalize_from_file(buf);
free(buf);
if (propsd == NULL) { if (propsd == NULL) {
printf("%s: unexistent metafile, converting to 0.18 " printf("%s: unexistent metafile, converting to 0.18 "
"format...\n", pkgname); "format...\n", pkgname);
@ -150,6 +152,7 @@ check_pkg_integrity(struct xbps_handle *xhp,
} else if (prop_dictionary_count(propsd) == 0) { } else if (prop_dictionary_count(propsd) == 0) {
xbps_error_printf("%s: incomplete metadata file.\n", pkgname); xbps_error_printf("%s: incomplete metadata file.\n", pkgname);
prop_object_release(propsd);
return 1; return 1;
} }
/* /*
@ -177,6 +180,7 @@ check_pkg_integrity(struct xbps_handle *xhp,
rv = xbps_file_hash_check(buf, sha256); rv = xbps_file_hash_check(buf, sha256);
free(buf); free(buf);
if (rv == ERANGE) { if (rv == ERANGE) {
prop_object_release(propsd);
fprintf(stderr, "%s: metadata file has been " fprintf(stderr, "%s: metadata file has been "
"modified!\n", pkgname); "modified!\n", pkgname);
return 1; return 1;
@ -199,6 +203,8 @@ do { \
RUN_PKG_CHECK(xhp, rundeps, propsd); RUN_PKG_CHECK(xhp, rundeps, propsd);
RUN_PKG_CHECK(xhp, unneeded, opkgd); RUN_PKG_CHECK(xhp, unneeded, opkgd);
prop_object_release(propsd);
#undef RUN_PKG_CHECK #undef RUN_PKG_CHECK
if ((rv == 0) && (pkgd == NULL)) if ((rv == 0) && (pkgd == NULL))

View File

@ -69,6 +69,7 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
prop_dictionary_get_cstring_nocopy(obj, prop_dictionary_get_cstring_nocopy(obj,
"sha256", &sha256); "sha256", &sha256);
rv = xbps_file_hash_check(path, sha256); rv = xbps_file_hash_check(path, sha256);
free(path);
switch (rv) { switch (rv) {
case 0: case 0:
break; break;
@ -93,7 +94,6 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
pkgname, file, strerror(rv)); pkgname, file, strerror(rv));
break; break;
} }
free(path);
} }
prop_object_iterator_release(iter); prop_object_iterator_release(iter);
} }

View File

@ -122,6 +122,9 @@ check_pkg_symlinks(struct xbps_handle *xhp, const char *pkgname, void *arg)
if (buf2 == NULL) { if (buf2 == NULL) {
xbps_warn_printf("%s: broken symlink %s (target: %s)\n", xbps_warn_printf("%s: broken symlink %s (target: %s)\n",
pkgname, file, tgt); pkgname, file, tgt);
free(path);
free(tgt_path);
free(p);
free(buf); free(buf);
free(lnk); free(lnk);
continue; continue;
@ -150,6 +153,7 @@ check_pkg_symlinks(struct xbps_handle *xhp, const char *pkgname, void *arg)
free(buf); free(buf);
free(path); free(path);
free(tgt_path); free(tgt_path);
free(lnk);
} }
return broken; return broken;
} }