]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cmd.c
Fix Windows-specific use-after-free causing crash after disconnecting
[xonotic/darkplaces.git] / cmd.c
diff --git a/cmd.c b/cmd.c
index 74f7eaff7674c2f3693298ce4f973295439f94eb..fedfb13dcbe52b86dfd7eaf0a2fcf8b7fe795ec7 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -1982,11 +1982,18 @@ const char **Cmd_CompleteAliasBuildList (cmd_state_t *cmd, const char *partial)
        return buf;
 }
 
-void Cmd_ClearCsqcFuncs (cmd_state_t *cmd)
+// TODO: Make this more generic?
+void Cmd_ClearCSQCCommands (cmd_state_t *cmd)
 {
        cmd_function_t *func;
-       for (func = cmd->userdefined->csqc_functions; func; func = func->next)
-               func->csqcfunc = false;
+       cmd_function_t **next = &cmd->userdefined->csqc_functions;
+       
+       while(*next)
+       {
+               func = *next;
+               *next = func->next;
+               Z_Free(func);
+       }
 }
 
 /*