protocol: Fix off-by-one when appending space in Protocol_Names master
authorCloudwalk <cloudwalk@icculus.org>
Mon, 4 Oct 2021 12:25:25 +0000 (08:25 -0400)
committerCloudwalk <cloudwalk@icculus.org>
Mon, 4 Oct 2021 12:25:25 +0000 (08:25 -0400)
cmd.c
protocol.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);
        }
index 5685675562e0e51096425f306fcbf741129f09f2..837ad97bed27445f804927f334b6b94440882747 100644 (file)
@@ -109,7 +109,7 @@ void Protocol_Names(char *buffer, size_t buffersize)
        buffer[0] = 0;
        for (i = 0;protocolversioninfo[i].name;i++)
        {
-               if (i > 1)
+               if (i > 0)
                        strlcat(buffer, " ", buffersize);
                strlcat(buffer, protocolversioninfo[i].name, buffersize);
        }