Fixed infinite execution of error CCMD

https://forum.zdoom.org/viewtopic.php?t=54659
This commit is contained in:
alexey.lysiuk 2016-12-22 11:00:20 +02:00 committed by Christoph Oelckers
parent b15e620ea8
commit 7dd51d6d1c

View file

@ -1523,8 +1523,6 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
buffer.Text.StripLeftRight();
Printf(127, TEXTCOLOR_WHITE "]%s\n", buffer.Text.GetChars());
AddCommandString(buffer.Text.LockBuffer());
buffer.Text.UnlockBuffer();
if (buffer.Text.Len() == 0)
{
@ -1568,7 +1566,21 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
}
}
HistPos = NULL;
buffer.SetString("");
{
// Work with a copy of command to avoid side effects caused by
// exception raised during execution, like with 'error' CCMD.
// It's problematic to maintain FString's lock symmetry.
static TArray<char> command;
const size_t length = buffer.Text.Len();
command.Resize(length + 1);
memcpy(&command[0], buffer.Text.GetChars(), length);
command[length] = '\0';
buffer.SetString("");
AddCommandString(&command[0]);
}
TabbedLast = false;
TabbedList = false;
break;