From: Ilho Kim Date: Wed, 24 Feb 2021 15:44:40 +0000 (+0900) Subject: Fix double free X-Git-Tag: submit/tizen/20210317.082331~112 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=20787b2cf7c60719e58921ee3832ca44913c3064;p=platform%2Fcore%2Fappfw%2Fpkgmgr-info.git Fix double free GHashTable's pointers will be catched PkgGetDBHandler Signed-off-by: Ilho Kim --- diff --git a/src/pkginfo_internal.c b/src/pkginfo_internal.c index 3465fec..a0fe7d8 100644 --- a/src/pkginfo_internal.c +++ b/src/pkginfo_internal.c @@ -20,9 +20,10 @@ #include "pkgmgrinfo_debug.h" #include "pkgmgr-info.h" -static void __free_packages(gpointer data) +static void __free_packages(gpointer key, gpointer value, + gpointer user_data) { - pkgmgrinfo_basic_free_package((package_x *)data); + pkgmgrinfo_basic_free_package((package_x *)value); } static const char join_localized_info[] = @@ -558,7 +559,7 @@ API int pkginfo_internal_filter_get_list( } list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, - __free_packages); + NULL); if (list == NULL) return PMINFO_R_ERROR; @@ -569,8 +570,9 @@ API int pkginfo_internal_filter_get_list( PMINFO_PKGINFO_GET_ALL, list); if (ret != PMINFO_R_OK) { + g_hash_table_foreach_remove(list, __free_packages, NULL); g_hash_table_destroy(list); - return PMINFO_R_ERROR; + return ret; } *pkginfo_list = list;