Fix pass null to g_hash_table_contains bug 18/216218/1
authorhyunho <hhstark.kang@samsung.com>
Tue, 22 Oct 2019 09:02:32 +0000 (18:02 +0900)
committerhyunho <hhstark.kang@samsung.com>
Tue, 22 Oct 2019 09:02:32 +0000 (18:02 +0900)
Change-Id: Ia3267518428da15c419984b7aeff9ec7b89c3037
Signed-off-by: hyunho <hhstark.kang@samsung.com>
src/service_common.c

index 0396194..a79ddf6 100755 (executable)
@@ -421,6 +421,19 @@ out:
        return result;
 }
 
+static int _init_pkg_privilege_info() {
+
+       if (_noti_pkg_privilege_info != NULL)
+               return 0;
+
+       _noti_pkg_privilege_info =
+               g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
+       _badge_pkg_privilege_info =
+               g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
+       DBG("init pkg privilege info done");
+       return 0;
+}
+
 static int _package_install_cb(uid_t uid, const char *pkgname, enum pkgmgr_status status, double value, void *data)
 {
        int ret;
@@ -433,6 +446,7 @@ static int _package_install_cb(uid_t uid, const char *pkgname, enum pkgmgr_statu
        if (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER))
                uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER);
 
+       _init_pkg_privilege_info();
        if (g_hash_table_contains(_noti_pkg_privilege_info, pkgname)) {
                tmp = g_hash_table_lookup(_noti_pkg_privilege_info, pkgname);
                privilege_info = GPOINTER_TO_UINT(tmp);
@@ -479,11 +493,7 @@ static int _package_uninstall_cb(uid_t uid, const char *pkgname, enum pkgmgr_sta
        if (ret == PMINFO_R_OK) {
                pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
 
-               if (_noti_pkg_privilege_info == NULL) {
-                       _noti_pkg_privilege_info = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
-                       _badge_pkg_privilege_info = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
-               }
-
+               _init_pkg_privilege_info();
                ret = notification_setting_db_update_pkg_disabled(pkgname, true, uid);
                if (ret == NOTIFICATION_ERROR_NONE)
                        g_hash_table_insert(_noti_pkg_privilege_info, strdup(pkgname), GUINT_TO_POINTER(1));