diff options
author | Seungha Son <seungha.son@samsung.com> | 2017-04-18 11:07:49 +0900 |
---|---|---|
committer | jusung son <jusung07.son@samsung.com> | 2017-04-18 20:59:43 +0900 |
commit | 1a2c42bd69a4d2358d033e893a8b479e6afa4aa0 (patch) | |
tree | c6789e0e57b4fb615974f55423bfd1748d21462c /src/notification_noti.c | |
parent | b760e937fccb4c40c479096d522829ec84887697 (diff) | |
download | notification-1a2c42bd69a4d2358d033e893a8b479e6afa4aa0.tar.gz notification-1a2c42bd69a4d2358d033e893a8b479e6afa4aa0.tar.bz2 notification-1a2c42bd69a4d2358d033e893a8b479e6afa4aa0.zip |
Fix memory leak
Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: Ia3e0492274d585781bf0a05e7b539bea48c44d89
Signed-off-by: jusung son <jusung07.son@samsung.com>
Diffstat (limited to 'src/notification_noti.c')
-rwxr-xr-x | src/notification_noti.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/notification_noti.c b/src/notification_noti.c index efdbf00..d9871f1 100755 --- a/src/notification_noti.c +++ b/src/notification_noti.c @@ -351,6 +351,11 @@ static int _insertion_query_create(notification_h noti, char **query) if (b_service_multi_launch) free(b_service_multi_launch); + for (i = 0; i <= NOTIFICATION_EVENT_TYPE_MAX; i++) { + if (b_event_handler[i]) + bundle_free_encoded_rawdata(&b_event_handler[i]); + } + if (b_text) free(b_text); @@ -527,6 +532,11 @@ static int _update_query_create(notification_h noti, char **query) if (b_service_multi_launch) free(b_service_multi_launch); + for (i = 0; i <= NOTIFICATION_EVENT_TYPE_MAX; i++) { + if (b_event_handler[i]) + bundle_free_encoded_rawdata(&b_event_handler[i]); + } + if (b_text) free(b_text); @@ -1106,7 +1116,8 @@ EXPORT_API int notification_noti_get_by_tag(notification_h noti, char *pkgname, "from noti_list where caller_pkgname = ? and tag = ? and uid = ?", -1, &stmt, NULL); if (ret != SQLITE_OK) { NOTIFICATION_ERR("Error: %s\n", sqlite3_errmsg(db)); - return NOTIFICATION_ERROR_OUT_OF_MEMORY; + ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; + goto err; } ret = sqlite3_bind_text(stmt, 1, pkgname, -1, SQLITE_TRANSIENT); @@ -1143,7 +1154,8 @@ EXPORT_API int notification_noti_get_by_tag(notification_h noti, char *pkgname, "from noti_list where tag = ? and uid = ?", -1, &stmt, NULL); if (ret != SQLITE_OK) { NOTIFICATION_ERR("Error: %s\n", sqlite3_errmsg(db)); - return NOTIFICATION_ERROR_OUT_OF_MEMORY; + ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; + goto err; } ret = sqlite3_bind_text(stmt, 1, tag, -1, SQLITE_TRANSIENT); @@ -1190,10 +1202,6 @@ EXPORT_API int notification_noti_update(notification_h noti) return NOTIFICATION_ERROR_INVALID_PARAMETER; } - db = notification_db_open(DBPATH); - if (!db) - return get_last_result(); - if (_is_allowed_to_notify(noti) == false) { NOTIFICATION_DBG("[%s] is not allowed to notify", noti->caller_pkgname); return NOTIFICATION_ERROR_PERMISSION_DENIED; @@ -1207,6 +1215,10 @@ EXPORT_API int notification_noti_update(notification_h noti) NOTIFICATION_DBG("notification display applist - pkgname [%s], applist [%d]", noti->caller_pkgname, noti->display_applist); } + db = notification_db_open(DBPATH); + if (!db) + return get_last_result(); + /* Check private ID is exist */ ret = _notification_noti_check_priv_id(noti, db); if (ret != NOTIFICATION_ERROR_ALREADY_EXIST_ID) { @@ -1815,7 +1827,6 @@ EXPORT_API int notification_noti_check_tag(notification_h noti) else result = 0; - sqlite3_finalize(stmt); /* If result > 0, there is priv_id in DB */ if (result > 0) { @@ -1826,6 +1837,8 @@ EXPORT_API int notification_noti_check_tag(notification_h noti) } err: + if (stmt != NULL) + sqlite3_finalize(stmt); if (db) notification_db_close(&db); @@ -1868,8 +1881,9 @@ EXPORT_API int notification_noti_check_count_for_template(notification_h noti, i *count = result; - sqlite3_finalize(stmt); err: + if (stmt != NULL) + sqlite3_finalize(stmt); if (db) notification_db_close(&db); @@ -2052,6 +2066,11 @@ static int _template_query_create(notification_h noti, char *template_name, char if (b_service_multi_launch) free(b_service_multi_launch); + for (i = 0; i <= NOTIFICATION_EVENT_TYPE_MAX; i++) { + if (b_event_handler[i]) + bundle_free_encoded_rawdata(&b_event_handler[i]); + } + if (b_text) free(b_text); |