]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cmd: Recycle input node before it executes. Avoids memory leak and infinite loop...
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 17 Sep 2020 15:24:55 +0000 (15:24 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 17 Sep 2020 15:24:55 +0000 (15:24 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12933 d7cf8633-e32d-0410-b094-e92efae38249

cmd.c

diff --git a/cmd.c b/cmd.c
index d0ef77505a872430ac6b9721444c16db46593fed..29eef47b443ea40389d77f2985c6b32426e53fd6 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -448,7 +448,10 @@ void Cbuf_Execute (cmd_buf_t *cbuf)
                 * can insert data at the beginning of the text buffer
                 */
                current = List_Container(*cbuf->start.next, cmd_input_t, list);
-
+               
+               // Recycle memory so using WASD doesn't cause a malloc and free
+               List_Move_Tail(&current->list, &cbuf->free);
+               
                /*
                 * Assume we're rolling with the current command-line and
                 * always set this false because alias expansion or cbuf insertion
@@ -473,9 +476,6 @@ void Cbuf_Execute (cmd_buf_t *cbuf)
                        Cmd_ExecuteString (current->source, current->text, src_local, false);
                }
 
-               // Recycle memory so using WASD doesn't cause a malloc and free
-               List_Move_Tail(&current->list, &cbuf->free);
-
                current = NULL;
 
                if (cbuf->wait)