From 8d9f5b65e3b98f3f00176013bd390813493a5a9e Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 18 Nov 2012 03:49:29 +0100 Subject: [PATCH] pkg_metadir: make sure to return a valid pkgd from the hash table. --- lib/package_metadir.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/package_metadir.c b/lib/package_metadir.c index 1e747617..566d5428 100644 --- a/lib/package_metadir.c +++ b/lib/package_metadir.c @@ -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);