From: jusung son Date: Tue, 22 Mar 2016 06:49:11 +0000 (+0900) Subject: Fix memory leak X-Git-Tag: accepted/tizen/common/20160324.084219^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=779dbe413df49381ade165b634f23ad20d6c5529;p=platform%2Fcore%2Fapi%2Fnotification.git Fix memory leak Change-Id: If66e60e8ccd7dff8d14b9e879ba390487932e76f Signed-off-by: jusung son --- diff --git a/src/notification_group.c b/src/notification_group.c index 3f4d718..21927ea 100755 --- a/src/notification_group.c +++ b/src/notification_group.c @@ -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; } diff --git a/src/notification_ipc.c b/src/notification_ipc.c index c2ce9ac..c449005 100755 --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@ -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; } diff --git a/src/notification_noti.c b/src/notification_noti.c index 75297e0..6987f67 100755 --- a/src/notification_noti.c +++ b/src/notification_noti.c @@ -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; }