Add exception in case pkgname is null 02/85902/2
authorMyungki Lee <mk5004.lee@samsung.com>
Tue, 30 Aug 2016 00:52:55 +0000 (09:52 +0900)
committerMyungki Lee <mk5004.lee@samsung.com>
Tue, 30 Aug 2016 00:52:55 +0000 (09:52 +0900)
- GLib-CRITICAL **: g_variant_new_string: assertion 'string != NULL' failed

Change-Id: I65a99c0c3031abd9dc9477adc78b0ba02d681d06
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
src/notification_ipc.c
src/notification_noti.c

index 3fbb1d3..be7b43c 100755 (executable)
@@ -863,6 +863,9 @@ int notification_ipc_request_delete_single(notification_type_e type, char *pkgna
                return result;
        }
 
+       if (!pkgname)
+               pkgname = "";
+
        body = g_variant_new("(sii)", pkgname, priv_id, uid);
        result = _send_sync_noti(body, &reply, "del_noti_single");
 
index e413268..114b893 100755 (executable)
@@ -1367,17 +1367,18 @@ EXPORT_API int notification_noti_delete_by_priv_id_get_changes(const char *pkgna
        char query[NOTIFICATION_QUERY_MAX] = {0, };
        int ret;
 
-       if (pkgname == NULL || strlen(pkgname) == 0)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
        db = notification_db_open(DBPATH);
        if (!db)
                return get_last_result();
 
-       snprintf(query, sizeof(query), "delete from noti_list "
-                "where caller_pkgname = '%s' and priv_id = %d and uid = %d", pkgname,
-                priv_id, uid);
-       NOTIFICATION_DBG("%s", query);
+       if (pkgname == NULL || strlen(pkgname) == 0) {
+               snprintf(query, sizeof(query), "delete from noti_list "
+                       "where priv_id = %d and uid = %d", priv_id, uid);
+       } else {
+               snprintf(query, sizeof(query), "delete from noti_list "
+                       "where caller_pkgname = '%s' and priv_id = %d and uid = %d",
+                       pkgname, priv_id, uid);
+       }
 
        ret = notification_db_exec(db, query, num_changes);