]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cmd: Check for empty cbuf when inserting too
authorCloudwalk <cloudwalk@icculus.org>
Sun, 19 Sep 2021 03:42:58 +0000 (23:42 -0400)
committerCloudwalk <cloudwalk@icculus.org>
Sun, 19 Sep 2021 03:42:58 +0000 (23:42 -0400)
cmd.c

diff --git a/cmd.c b/cmd.c
index e8f168896d963c39ed1c9673e3aaaa2f2f4d5c86..a12fae8ea0c4fa52839d66a46267e73b927936bf 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -394,7 +394,7 @@ void Cbuf_InsertText (cmd_state_t *cmd, const char *text)
                Con_Print("Cbuf_InsertText: overflow\n");
        else
        {
                Con_Print("Cbuf_InsertText: overflow\n");
        else
        {
-               Cbuf_LinkCreate(cmd, &llist, List_Entry(cbuf->start.next, cmd_input_t, list), text);
+               Cbuf_LinkCreate(cmd, &llist, (List_Is_Empty(&cbuf->start) ? NULL : List_Entry(cbuf->start.next, cmd_input_t, list)), text);
                if(!List_Is_Empty(&llist))
                        List_Splice(&llist, &cbuf->start);
        }
                if(!List_Is_Empty(&llist))
                        List_Splice(&llist, &cbuf->start);
        }