Add null checker 82/166782/2
authorSeungha Son <seungha.son@samsung.com>
Fri, 12 Jan 2018 02:00:09 +0000 (11:00 +0900)
committerSeungha Son <seungha.son@samsung.com>
Fri, 12 Jan 2018 02:08:41 +0000 (11:08 +0900)
Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: I77c016ccaa3ab08e0e2993b4d5d95fbd46f0bb39

src/notification_noti.c

index 37a4ab43be425ae700df66bbd4946dc729940648..4fc8deecf5659b13fe5a6a92ae330462cdb6baef 100755 (executable)
@@ -660,6 +660,10 @@ static int _get_notification_list(char *query_where, notification_list_h *list,
                if (noti == NULL) {
                        /* LCOV_EXCL_START */
                        ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+                       if (get_list) {
+                               get_list = notification_list_get_head(get_list);
+                               notification_free_list(get_list);
+                       }
                        goto err;
                        /* LCOV_EXCL_STOP */
                }
@@ -676,6 +680,12 @@ static int _get_notification_list(char *query_where, notification_list_h *list,
                }
        }
 
+       if (get_list != NULL) {
+               *list = notification_list_get_head(get_list);
+               if (list_count)
+                       *list_count = internal_count;
+       }
+
 err:
        if (stmt)
                sqlite3_finalize(stmt);
@@ -683,11 +693,6 @@ err:
        if (db != NULL)
                notification_db_close(&db);
 
-       if (get_list != NULL) {
-               *list = notification_list_get_head(get_list);
-               *list_count = internal_count;
-       }
-
        return ret;
 }
 int notification_noti_set_tag(const char *tag, char *value, char *buf, int buf_len)