From 2ecb22699676d203a2ffb00ad641df1a53821091 Mon Sep 17 00:00:00 2001 From: Fradet Date: Sun, 23 Jun 2024 23:23:04 +0200 Subject: [PATCH 1/2] fix: double free when AI died --- server/Makefile | 2 +- server/src/ai/die.c | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/server/Makefile b/server/Makefile index ddcdaef1..6632fbd8 100644 --- a/server/Makefile +++ b/server/Makefile @@ -149,7 +149,7 @@ NAME = zappy_server # Flags INCLUDE = -I./include -CXXFLAGS = -Wall -Wextra -Werror -lm +CXXFLAGS = -Wall -Wextra -Werror -lm -g # Colors YELLOW = /bin/echo -e "\x1b[33m $1\x1b[0m" diff --git a/server/src/ai/die.c b/server/src/ai/die.c index 8a64e86f..035245ec 100644 --- a/server/src/ai/die.c +++ b/server/src/ai/die.c @@ -44,17 +44,6 @@ void free_ai(app_t *app, ia_t *ai) static void ia_die(app_t *app, ia_t *ai) { - list_node_t *temp_command = ai->list_command->first; - list_node_t *temp_message = ai->list_messages->first; - - while (temp_command) { - free(temp_command->data.command); - temp_command = temp_command->next; - } - while (temp_message) { - free(temp_message->data.message); - temp_message = temp_message->next; - } ai->dead = true; dead_response(ai); pdi_command(app, ai->fd); From fbcdcd5c6954a118cefd6d38c504ba0e52359632 Mon Sep 17 00:00:00 2001 From: Fradet Date: Sun, 23 Jun 2024 23:24:30 +0200 Subject: [PATCH 2/2] fix: remove flag in compilation --- server/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/Makefile b/server/Makefile index 6632fbd8..ddcdaef1 100644 --- a/server/Makefile +++ b/server/Makefile @@ -149,7 +149,7 @@ NAME = zappy_server # Flags INCLUDE = -I./include -CXXFLAGS = -Wall -Wextra -Werror -lm -g +CXXFLAGS = -Wall -Wextra -Werror -lm # Colors YELLOW = /bin/echo -e "\x1b[33m $1\x1b[0m"