protocol: Fix off-by-one when appending space in Protocol_Names
[xonotic/darkplaces.git] / 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
        {
-               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);
        }