diff options
author | Seungha Son <seungha.son@samsung.com> | 2017-04-18 11:07:49 +0900 |
---|---|---|
committer | Seungha Son <seungha.son@samsung.com> | 2017-04-20 09:38:41 +0900 |
commit | 8cd22103062d15b73ca0e4d1bc634771d0aa0a98 (patch) | |
tree | 6c6aa54a6e66488fec6c0fa758dc712e662f8c24 | |
parent | e41d1b0a02cc4beecb190edb9759ed2099daae3b (diff) | |
download | notification-submit/tizen_3.0/20170420.011011.tar.gz notification-submit/tizen_3.0/20170420.011011.tar.bz2 notification-submit/tizen_3.0/20170420.011011.zip |
Fix memory leaksubmit/tizen_3.0_common/20170508.091735submit/tizen_3.0/20170420.011011submit/tizen_3.0-common/20170508.091535submit/tizen_3.0-common/20170508.081301submit/tizen_3.0-common/20170508.080135accepted/tizen/3.0/wearable/20170508.050205accepted/tizen/3.0/tv/20170508.050153accepted/tizen/3.0/mobile/20170508.050133accepted/tizen/3.0/ivi/20170508.050220accepted/tizen/3.0/common/20170508.152937
Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: Ia3e0492274d585781bf0a05e7b539bea48c44d89
Signed-off-by: jusung son <jusung07.son@samsung.com>
-rwxr-xr-x | src/notification_noti.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/notification_noti.c b/src/notification_noti.c index 07b6b62..1845833 100755 --- a/src/notification_noti.c +++ b/src/notification_noti.c @@ -22,6 +22,7 @@ #include <pkgmgr-info.h> #include <package_manager.h> #include <app_control_internal.h> +#include <bundle_internal.h> #include <notification.h> #include <notification_internal.h> @@ -348,6 +349,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((bundle_raw **)&b_event_handler[i]); + } + if (b_text) free(b_text); @@ -522,6 +528,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((bundle_raw **)&b_event_handler[i]); + } + if (b_text) free(b_text); @@ -1132,7 +1143,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); @@ -1168,7 +1180,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); @@ -1215,10 +1228,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; @@ -1232,6 +1241,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) { @@ -1838,7 +1851,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) { @@ -1849,6 +1861,8 @@ EXPORT_API int notification_noti_check_tag(notification_h noti) } err: + if (stmt != NULL) + sqlite3_finalize(stmt); if (db) notification_db_close(&db); @@ -1891,8 +1905,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); @@ -2073,6 +2088,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((bundle_raw **)&b_event_handler[i]); + } + if (b_text) free(b_text); |