pkg_metadir: make sure to return a valid pkgd from the hash table.

This commit is contained in:
Juan RP 2012-11-18 03:49:29 +01:00
parent 46f7a808b4
commit 8d9f5b65e3

View File

@ -59,8 +59,8 @@ metadir_get(const char *name)
struct pkgmeta *pm;
HASH_FIND_STR(pkgmetas, __UNCONST(name), pm);
if (pm)
return pm->d;
if (pm != NULL && pm->d != NULL)
return prop_dictionary_copy(pm->d);
return NULL;
}
@ -70,6 +70,8 @@ metadir_add(const char *name, prop_dictionary_t d)
{
struct pkgmeta *pm;
assert(prop_object_type(d) == PROP_TYPE_DICTIONARY);
/* Add pkg plist to hash map */
pm = malloc(sizeof(*pm));
assert(pm);