From f94e00d66fbebd1108d0cc59e96b176456c0b322 Mon Sep 17 00:00:00 2001 From: braxi Date: Wed, 11 Sep 2024 23:25:04 +0200 Subject: [PATCH] dezefix --- src/tools/tools_shared.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tools/tools_shared.cpp b/src/tools/tools_shared.cpp index 06963c73..1cfbfcfb 100644 --- a/src/tools/tools_shared.cpp +++ b/src/tools/tools_shared.cpp @@ -358,7 +358,13 @@ char* Com_Parse(char* data) void Com_Tokenize(char* text) { - memset(com_argv, 0, sizeof(char*) * MAX_ARGS); + // clear the args from the last string + for (int i = 0; i < com_argc; i++) + free(com_argc[i]); + + //cmd_argc = 0; + com_args[0] = 0; + com_argc = 0; com_args = NULL; @@ -390,7 +396,7 @@ void Com_Tokenize(char* text) if (com_argc < MAX_ARGS) { - com_argv[com_argc] = new char[strlen(com_token) + 1]; + com_argv[com_argc] = (char*)malloc(strlen(com_token) + 1); strcpy(com_argv[com_argc], com_token); com_argc++; }