Fix memory leak 14/63114/2 accepted/tizen/common/20160324.084219 accepted/tizen/common/20160325.134911 accepted/tizen/ivi/20160324.131621 accepted/tizen/mobile/20160324.132906 accepted/tizen/tv/20160324.132728 accepted/tizen/wearable/20160324.132652 submit/tizen/20160323.065638 submit/tizen/20160323.235918
authorjusung son <jusung07.son@samsung.com>
Tue, 22 Mar 2016 06:49:11 +0000 (15:49 +0900)
committerSemun Lee <sm79.lee@samsung.com>
Wed, 23 Mar 2016 06:52:28 +0000 (23:52 -0700)
Change-Id: If66e60e8ccd7dff8d14b9e879ba390487932e76f
Signed-off-by: jusung son <jusung07.son@samsung.com>
src/notification_group.c
src/notification_ipc.c
src/notification_noti.c

index 3f4d718..21927ea 100755 (executable)
@@ -173,6 +173,8 @@ int notification_group_get_badge(const char *pkgname,
                NOTIFICATION_ERR("Select Query : %s", query);
                NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
                                 sqlite3_errmsg(db));
+               if (db)
+                       notification_db_close(&db);
 
                return NOTIFICATION_ERROR_FROM_DB;
        }
index c2ce9ac..c449005 100755 (executable)
@@ -1435,7 +1435,7 @@ static gboolean _variant_to_int_dict(GHashTable **dict, GVariant *variant) {
        while (g_variant_iter_next(&iter, "{iv}", &key, &value)) {
                hash_key = (int *)calloc(sizeof(int), 1);
                if (hash_key == NULL) {
-                       g_hash_table_remove_all(*dict);
+                       g_hash_table_unref(*dict);
                        return FALSE;
                }
                *hash_key = key;
@@ -1589,7 +1589,7 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti,
        noti->temp_content = _dup_string(temp_content);
        noti->tag = _dup_string(tag);
 
-       g_hash_table_remove_all(dict);
+       g_hash_table_unref(dict);
 
        return NOTIFICATION_ERROR_NONE;
 }
index 75297e0..6987f67 100755 (executable)
@@ -940,18 +940,12 @@ EXPORT_API int notification_noti_insert(notification_h noti)
        ret = _notification_noti_bind_query_double(stmt, "$progress_size", noti->progress_size);
        if (ret != NOTIFICATION_ERROR_NONE) {
                NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
-               if (stmt)
-                       sqlite3_finalize(stmt);
-
-               return ret;
+               goto err;
        }
        ret = _notification_noti_bind_query_double(stmt, "$progress_percentage", noti->progress_percentage);
        if (ret != NOTIFICATION_ERROR_NONE) {
                NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
-               if (stmt)
-                       sqlite3_finalize(stmt);
-
-               return ret;
+               goto err;
        }
 
        ret = sqlite3_step(stmt);
@@ -1917,6 +1911,8 @@ EXPORT_API int notification_noti_check_tag(notification_h noti)
        ret = sqlite3_prepare_v2(db, "SELECT priv_id FROM noti_list WHERE caller_pkgname = ? and tag = ?", -1, &stmt, NULL);
        if (ret != SQLITE_OK) {
                NOTIFICATION_ERR("Error: %s\n", sqlite3_errmsg(db));
+               if (db)
+                       notification_db_close(&db);
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
 
@@ -1949,6 +1945,8 @@ EXPORT_API int notification_noti_check_tag(notification_h noti)
        }
 
 err:
+       if (db)
+               notification_db_close(&db);
 
        return ret;
 }