diff --git a/Quake/cmd.c b/Quake/cmd.c index 4d41a59e..b14143ab 100644 --- a/Quake/cmd.c +++ b/Quake/cmd.c @@ -165,9 +165,16 @@ void Cbuf_Execute (void) break; } - - memcpy (line, text, i); - line[i] = 0; + if (i > (int)sizeof(line) - 1) + { + memcpy (line, text, sizeof(line) - 1); + line[sizeof(line) - 1] = 0; + } + else + { + memcpy (line, text, i); + line[i] = 0; + } // delete the text from the command buffer and move remaining commands down // this is necessary because commands (exec, alias) can insert data at the