From 963e75da51e87d8f30ebf190a273b63a6135e2c1 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Wed, 28 Aug 2024 13:21:33 +0200 Subject: [PATCH] clearing arg on command --- src/chat/main/client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/chat/main/client.c b/src/chat/main/client.c index 57fd971..33f31f9 100644 --- a/src/chat/main/client.c +++ b/src/chat/main/client.c @@ -54,6 +54,10 @@ why2_bool command(char *input, char *command, char **arg) char *full_cmd = why2_malloc(strlen(WHY2_CHAT_COMMAND_PREFIX) + strlen(WHY2_CHAT_COMMAND_EXIT) + 2); sprintf(full_cmd, WHY2_CHAT_COMMAND_PREFIX "%s", command); + //CLEAR arg + why2_deallocate(*arg); //DEALLOCATION (why2_deallocate fn checks for NULL, don't you worry) + *arg = NULL; + if (strncmp(input, full_cmd, strlen(full_cmd)) == 0) //COMMAND WAS EXECUTED { if (strlen(full_cmd) == strlen(input) - 1) //COMMAND DOESN'T HAVE ARGS @@ -62,7 +66,6 @@ why2_bool command(char *input, char *command, char **arg) } else if (strlen(input) - 2 > strlen(full_cmd) && input[strlen(full_cmd)] == ' ') //COMMAND CONTAINS ARGS { returning = 1; - why2_deallocate(*arg); //DEALLOCATION (why2_deallocate fn checks for NULL, don't you worry) //GET THE ARGS *arg = why2_malloc(strlen(input) - strlen(full_cmd) - 1); //ALLOCATE