xbps_find_pkg_dict_installed: dictionary MUST be copied before calling
xbps_regpkgs_dictionary_release(), otherwise it will be NULL. Found by executing this function without initializing regpkgdb.
This commit is contained in:
parent
756a5ec654
commit
ab10cc3b15
14
lib/plist.c
14
lib/plist.c
@ -158,7 +158,7 @@ xbps_find_pkg_from_plist(const char *plist, const char *pkgname)
|
|||||||
prop_dictionary_t
|
prop_dictionary_t
|
||||||
xbps_find_pkg_dict_installed(const char *str, bool bypattern)
|
xbps_find_pkg_dict_installed(const char *str, bool bypattern)
|
||||||
{
|
{
|
||||||
prop_dictionary_t d, pkgd;
|
prop_dictionary_t d, pkgd, rpkgd = NULL;
|
||||||
pkg_state_t state = 0;
|
pkg_state_t state = 0;
|
||||||
|
|
||||||
if ((d = xbps_regpkgs_dictionary_init()) == NULL)
|
if ((d = xbps_regpkgs_dictionary_init()) == NULL)
|
||||||
@ -169,25 +169,25 @@ xbps_find_pkg_dict_installed(const char *str, bool bypattern)
|
|||||||
else
|
else
|
||||||
pkgd = xbps_find_pkg_in_dict_by_name(d, "packages", str);
|
pkgd = xbps_find_pkg_in_dict_by_name(d, "packages", str);
|
||||||
if (pkgd == NULL)
|
if (pkgd == NULL)
|
||||||
goto fail;
|
goto out;
|
||||||
|
|
||||||
if (xbps_get_pkg_state_dictionary(pkgd, &state) != 0)
|
if (xbps_get_pkg_state_dictionary(pkgd, &state) != 0)
|
||||||
goto fail;
|
goto out;
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case XBPS_PKG_STATE_INSTALLED:
|
case XBPS_PKG_STATE_INSTALLED:
|
||||||
case XBPS_PKG_STATE_UNPACKED:
|
case XBPS_PKG_STATE_UNPACKED:
|
||||||
xbps_regpkgs_dictionary_release();
|
rpkgd = prop_dictionary_copy(pkgd);
|
||||||
return prop_dictionary_copy(pkgd);
|
break;
|
||||||
case XBPS_PKG_STATE_CONFIG_FILES:
|
case XBPS_PKG_STATE_CONFIG_FILES:
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fail:
|
out:
|
||||||
xbps_regpkgs_dictionary_release();
|
xbps_regpkgs_dictionary_release();
|
||||||
return NULL;
|
return rpkgd;
|
||||||
}
|
}
|
||||||
|
|
||||||
prop_dictionary_t
|
prop_dictionary_t
|
||||||
|
Loading…
Reference in New Issue
Block a user