Fix memory leak 30/154430/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 10 Oct 2017 07:49:44 +0000 (16:49 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 10 Oct 2017 07:49:44 +0000 (16:49 +0900)
Change-Id: I31809c353bdd3ec63cb79151b8018a1e0c30ad5f
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/pkgmgrinfo_appinfo.c
src/pkgmgrinfo_pkginfo.c

index da7d2ac..0e8cf33 100644 (file)
@@ -721,7 +721,8 @@ static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
        if (locale == NULL)
                return PMINFO_R_ERROR;
 
-       list = g_hash_table_new(g_str_hash, g_str_equal);
+       list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+                       __free_applications);
        if (list == NULL) {
                free(locale);
                return PMINFO_R_ERROR;
@@ -760,6 +761,7 @@ static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
        info->package = strdup(info->app_info->package);
 
        /* just free list only */
+       g_hash_table_steal(list, (gconstpointer)appid);
        g_hash_table_destroy(list);
 
        *handle = info;
index 43f2d87..22ed01b 100644 (file)
@@ -699,7 +699,8 @@ static int _pkgmgrinfo_get_pkginfo(const char *pkgid, uid_t uid,
        if (locale == NULL)
                return PMINFO_R_ERROR;
 
-       list = g_hash_table_new(g_str_hash, g_str_equal);
+       list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+                       __free_packages);
        if (list == NULL) {
                free(locale);
                return PMINFO_R_ERROR;
@@ -738,6 +739,7 @@ static int _pkgmgrinfo_get_pkginfo(const char *pkgid, uid_t uid,
        info->locale = locale;
 
        /* just free list only */
+       g_hash_table_steal(list, (gconstpointer)pkgid);
        g_hash_table_destroy(list);
 
        *handle = info;
@@ -826,7 +828,8 @@ API int pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(const char *pkgid,
                return PMINFO_R_ERROR;
        }
 
-       list = g_hash_table_new(g_str_hash, g_str_equal);
+       list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+                       __free_packages);
        if (list == NULL) {
                pkgmgrinfo_pkginfo_filter_destroy(filter);
                free(locale);
@@ -867,6 +870,7 @@ API int pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(const char *pkgid,
        info->locale = locale;
 
        /* just free list only */
+       g_hash_table_steal(list, (gconstpointer)pkgid);
        g_hash_table_destroy(list);
 
        *handle = info;