diff options
author | mk5004.lee <mk5004.lee@samsung.com> | 2019-01-04 13:15:26 +0900 |
---|---|---|
committer | mk5004.lee <mk5004.lee@samsung.com> | 2019-01-04 14:28:07 +0900 |
commit | 4f0e15c60efc4f6c90cbdeb297ec1ce6386941be (patch) | |
tree | c29bfb9d807dc9b0df5446bf71b6152a1907a424 | |
parent | 2508afb096f4706e6130efdb36565a0f8e89f72a (diff) | |
download | notification-4f0e15c60efc4f6c90cbdeb297ec1ce6386941be.tar.gz notification-4f0e15c60efc4f6c90cbdeb297ec1ce6386941be.tar.bz2 notification-4f0e15c60efc4f6c90cbdeb297ec1ce6386941be.zip |
Fix resource leaks
Change-Id: I625d2dd3046819f827b208ef4259b9187768ae78
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
-rwxr-xr-x | src/notification.c | 4 | ||||
-rwxr-xr-x | src/notification_internal.c | 2 | ||||
-rwxr-xr-x | src/notification_ipc.c | 16 | ||||
-rwxr-xr-x | src/notification_noti.c | 1 | ||||
-rwxr-xr-x | src/notification_shared_file.c | 20 |
5 files changed, 23 insertions, 20 deletions
diff --git a/src/notification.c b/src/notification.c index 6b22208..4a296d1 100755 --- a/src/notification.c +++ b/src/notification.c @@ -140,6 +140,10 @@ EXPORT_API int notification_set_image(notification_h noti, bundle_add_str(priv_b, buf_key, priv_path); noti->b_priv_image_path = priv_b; } + + if (priv_path) + free(priv_path); + return NOTIFICATION_ERROR_NONE; } diff --git a/src/notification_internal.c b/src/notification_internal.c index 562e0bf..906aabf 100755 --- a/src/notification_internal.c +++ b/src/notification_internal.c @@ -1689,7 +1689,7 @@ EXPORT_API int notification_post_with_event_cb_for_uid(notification_h noti, even info->cb = cb; info->userdata = userdata; } else { - info = (notification_event_cb_info_s *)malloc(sizeof(notification_cb_info_s)); + info = (notification_event_cb_info_s *)malloc(sizeof(notification_event_cb_info_s)); if (info == NULL) { /* LCOV_EXCL_START */ NOTIFICATION_ERR("Failed to alloc memory"); diff --git a/src/notification_ipc.c b/src/notification_ipc.c index 8b9a827..77c1f45 100755 --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@ -376,7 +376,7 @@ static void _add_noti_notify(GVariant *parameters) { int ret; notification_h noti; - notification_op *noti_op; + notification_op *noti_op = NULL; GVariant *body = NULL; uid_t uid; @@ -397,13 +397,13 @@ static void _add_noti_notify(GVariant *parameters) /* Enable changed cb */ noti_op = _ipc_create_op(NOTIFICATION_OP_INSERT, 1, &(noti->priv_id), 1, ¬i); ret = notification_get_uid(noti, &uid); - if (noti_op != NULL && ret == NOTIFICATION_ERROR_NONE) { + if (noti_op != NULL && ret == NOTIFICATION_ERROR_NONE) notification_call_changed_cb_for_uid(noti_op, 1, uid); - free(noti_op); - } } g_variant_unref(body); notification_free(noti); + if (noti_op) + free(noti_op); } /* LCOV_EXCL_STOP */ @@ -412,7 +412,7 @@ static void _update_noti_notify(GVariant *parameters) { int ret; notification_h noti; - notification_op *noti_op; + notification_op *noti_op = NULL; GVariant *body = NULL; uid_t uid; @@ -428,13 +428,13 @@ static void _update_noti_notify(GVariant *parameters) noti_op = _ipc_create_op(NOTIFICATION_OP_UPDATE, 1, &(noti->priv_id), 1, ¬i); ret = notification_get_uid(noti, &uid); - if (noti_op != NULL && ret == NOTIFICATION_ERROR_NONE) { + if (noti_op != NULL && ret == NOTIFICATION_ERROR_NONE) notification_call_changed_cb_for_uid(noti_op, 1, uid); - free(noti_op); - } g_variant_unref(body); notification_free(noti); + if (noti_op) + free(noti_op); } /* LCOV_EXCL_STOP */ diff --git a/src/notification_noti.c b/src/notification_noti.c index 6d36e0a..87ac200 100755 --- a/src/notification_noti.c +++ b/src/notification_noti.c @@ -963,6 +963,7 @@ static int _check_text_input(notification_h noti) NOTIFICATION_ERR("Event handler for text_input is not set"); return -1; } + app_control_destroy(app_control); } return NOTIFICATION_ERROR_NONE; diff --git a/src/notification_shared_file.c b/src/notification_shared_file.c index 9bf91e6..cf44970 100755 --- a/src/notification_shared_file.c +++ b/src/notification_shared_file.c @@ -782,7 +782,7 @@ int __set_sharing_for_new_target(sharing_req_data_s *req_data, private_sharing_req *handle = NULL; GList *iter, *tmp; target_app_info_s *target_info; - char *app_info; + char *app_info = NULL; iter = target_app_list; for (; iter != NULL; iter = g_list_next(iter)) { @@ -853,6 +853,8 @@ int __set_sharing_for_new_target(sharing_req_data_s *req_data, } out: + if (ret != NOTIFICATION_ERROR_NONE && app_info) + free(app_info); if (handle != NULL) security_manager_private_sharing_req_free(handle); if (path_array != NULL) @@ -965,7 +967,6 @@ EXPORT_API int notification_set_private_sharing(notification_h noti, uid_t uid) { int ret = NOTIFICATION_ERROR_NONE; - char *shared_dir; bool is_overlapping = false; sharing_req_data_s *req_data; sharing_file_info_s *file_info, *dup_file_info; @@ -976,10 +977,6 @@ EXPORT_API int notification_set_private_sharing(notification_h noti, if (noti == NULL || noti->caller_app_id == NULL) return NOTIFICATION_ERROR_INVALID_PARAMETER; - shared_dir = __get_shared_dir(noti); - if (shared_dir == NULL) - return NOTIFICATION_ERROR_NONE; - tmp = g_list_find_custom(__uid_list, GINT_TO_POINTER(uid), __comp_uid_info_list); if (tmp == NULL) { @@ -1002,9 +999,11 @@ EXPORT_API int notification_set_private_sharing(notification_h noti, __OOM_CHECK(req_data->app_id, NOTIFICATION_ERROR_OUT_OF_MEMORY, __free_req_info(req_data)); - req_data->dir = strdup(shared_dir); - __OOM_CHECK(req_data->dir, NOTIFICATION_ERROR_OUT_OF_MEMORY, - __free_req_info(req_data)); + req_data->dir = __get_shared_dir(noti); + if (req_data->dir == NULL) { + __free_req_info(req_data); + return NOTIFICATION_ERROR_INVALID_PARAMETER; + } uid_info->sharing_req_list = g_list_append( uid_info->sharing_req_list, req_data); @@ -1012,8 +1011,7 @@ EXPORT_API int notification_set_private_sharing(notification_h noti, req_data = (sharing_req_data_s *)req_list->data; } - __make_sharing_dir(shared_dir); - free(shared_dir); + __make_sharing_dir(req_data->dir); tmp = g_list_find_custom(req_data->priv_id_list, GINT_TO_POINTER(noti->priv_id), __comp_priv_id); |