From be47d1b13f66a8341419fa4545a5ff6a5ec0b025 Mon Sep 17 00:00:00 2001 From: n-isaka Date: Thu, 31 Jul 2025 13:46:51 +0000 Subject: [PATCH 1/2] fix(call): call stack cleanup when cancel all. * Fixed the program stack list to be initialized every time CANCEL ALL is executed. --- libcob/call.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libcob/call.c b/libcob/call.c index 2ba402b..de39c7c 100644 --- a/libcob/call.c +++ b/libcob/call.c @@ -294,10 +294,10 @@ init_call_stack_list (void) static struct call_stack_list * cob_create_call_stack_list (char *name) { - struct call_stack_list *new_list = cob_malloc (sizeof (struct call_stack_list)); + struct call_stack_list *new_list = malloc (sizeof (struct call_stack_list)); memset (new_list, 0, sizeof (struct call_stack_list)); new_list->parent = current_call_stack_list; - new_list->name = cob_malloc (strlen (name) + 1); + new_list->name = malloc (strlen (name) + 1); strcpy (new_list->name, name); current_call_stack_list = new_list; return new_list; @@ -319,6 +319,8 @@ cob_cancel_call_stack_list (struct call_stack_list *p) if (p->sister) { cob_cancel_call_stack_list (p->sister); } + free (p->name); + free (p); } const char * @@ -784,5 +786,6 @@ cob_cancel_all () return; } cob_cancel_call_stack_list (current_call_stack_list->children); + current_call_stack_list->children = NULL; return; } From d93d607b6ec7c1b71ccb5193585133e14fd9f314 Mon Sep 17 00:00:00 2001 From: n-isaka Date: Fri, 1 Aug 2025 11:38:51 +0000 Subject: [PATCH 2/2] ref(call): refactor code to strdup --- libcob/call.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libcob/call.c b/libcob/call.c index de39c7c..7497e7c 100644 --- a/libcob/call.c +++ b/libcob/call.c @@ -297,8 +297,7 @@ cob_create_call_stack_list (char *name) struct call_stack_list *new_list = malloc (sizeof (struct call_stack_list)); memset (new_list, 0, sizeof (struct call_stack_list)); new_list->parent = current_call_stack_list; - new_list->name = malloc (strlen (name) + 1); - strcpy (new_list->name, name); + new_list->name = strdup (name); current_call_stack_list = new_list; return new_list; }