From: saerome kim Date: Tue, 10 Oct 2017 10:39:10 +0000 (+0900) Subject: Fix resource leak : 23614 X-Git-Tag: accepted/tizen/unified/20171011.070005^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fzigbee-manager.git;a=commitdiff_plain;h=3244c574f8b5858734e5c02620aaa87ad270ceec Fix resource leak : 23614 This problem is caused by managing a number of operations to be processed asynchronously in the initialization list. If the initialization of a function that needs to be processed asynchronously fails, we did not free the previously added asynchronous functions. To solve this problem, we modified the asynchronous initialization function list to be deleted from the memory when the function creation to be processed asynchronously fails and when the plugin is unloaded. Change-Id: I66226faedb360d7c2f41fd35db516a63684e112d Signed-off-by: saerome kim --- diff --git a/zigbee-daemon/zigbee-lib/src/zblib_service.c b/zigbee-daemon/zigbee-lib/src/zblib_service.c index f512514..2bfb853 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_service.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_service.c @@ -266,6 +266,22 @@ static void __zblib_service_remove_request_table_iter(gpointer key, zblib_request_free(service_interface, request_id); } +static void __zblib_service_remove_async_list(GSList *list_async) +{ + GSList *iter = NULL; + if (0 < g_slist_length(list_async)) { + iter = g_slist_nth(list_async, 0); + while (iter) { + if (iter) { + struct _zblib_async_init_info *async_plugin = + (struct _zblib_async_init_info *)(list_async->data); + list_async = g_slist_remove(list_async, async_plugin); + } + iter = g_slist_nth(list_async, 0); + } + } +} + ZigBeeService *zblib_service_new() { ZigBeeService *service; @@ -473,6 +489,7 @@ gboolean zblib_service_initialize_plugins(ZigBeeService *service) list_async = g_slist_append(list_async, info); } else { + __zblib_service_remove_async_list(list_async); Z_LOGE("Fatal : Failed to initialize plugin"); return FALSE; } @@ -517,10 +534,15 @@ gboolean zblib_service_initialize_async_plugins(ZigBeeService *service) gboolean zblib_service_unload_plugins(ZigBeeService *service) { - GSList *list; + GSList *list = NULL; + GSList *list_async = NULL; zblib_check_null_ret_error("service", service, FALSE); + /* Unload everyy async_plugin */ + list_async = __zblib_service_ref_async_initializer(service); + __zblib_service_remove_async_list(list_async); + list = zblib_service_ref_plugins(service); while (list != NULL) { ZigBeePlugin *plugin = list->data;