From 1d206f54a56d957cd2a5201012dd940c0014caf9 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 1 Oct 2021 17:51:29 +0900 Subject: [PATCH] Fix memory leak when remove item from g_list Change-Id: Iea82db5c35455bbf180bb160d217a7188780ec72 Signed-off-by: Suyeon Hwang --- common/vc_command.c | 4 ++-- common/vc_config_mgr.c | 3 +-- server/vcd_server.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/common/vc_command.c b/common/vc_command.c index 665f8d9..25eabf9 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -244,7 +244,7 @@ int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool release_command) return VC_ERROR_INVALID_PARAMETER; } - g_cmdlist_list = g_list_remove_link(g_cmdlist_list, iter); + g_cmdlist_list = g_list_delete_link(g_cmdlist_list, iter); vc_cmd_list_remove_all((vc_cmd_list_h)list, release_command); free(list); @@ -751,7 +751,7 @@ int vc_cmd_destroy(vc_cmd_h vc_command) return VC_ERROR_INVALID_PARAMETER; } - g_cmd_list = g_list_remove_link(g_cmd_list, iter); + g_cmd_list = g_list_delete_link(g_cmd_list, iter); if (command->command) free(command->command); diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c index 5d5fd12..f1c351b 100644 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -564,8 +564,7 @@ static int __vc_config_mgr_unregister_engine_config_updated_event() tmp = NULL; } - g_ino_list = g_list_remove_link(g_ino_list, iter); - + g_ino_list = g_list_delete_link(g_ino_list, iter); iter = g_list_first(g_ino_list); } } diff --git a/server/vcd_server.c b/server/vcd_server.c index a89732f..e80bc14 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1347,7 +1347,7 @@ bool vcd_finalize() if (0 < g_list_length(g_proc_list)) { iter = g_list_first(g_proc_list); while (NULL != iter) { - g_proc_list = g_list_remove_link(g_proc_list, iter); + g_proc_list = g_list_delete_link(g_proc_list, iter); iter = g_list_first(g_proc_list); } } @@ -1430,7 +1430,7 @@ static void __read_proc() if (0 < g_list_length(g_proc_list)) { iter = g_list_first(g_proc_list); while (NULL != iter) { - g_proc_list = g_list_remove_link(g_proc_list, iter); + g_proc_list = g_list_delete_link(g_proc_list, iter); iter = g_list_first(g_proc_list); } } -- 2.7.4