Fix segfault

svn-id: r5988
This commit is contained in:
James Brown 2002-12-16 03:21:38 +00:00
parent 48a9679c19
commit 4c831704cd

View file

@ -154,6 +154,9 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers)
int len = _promptEndPos - _promptStartPos;
char str[len + 1];
if (len < 0) len = 0; // Prevent overflow from forced Ctrl-D deletion
for (i = 0; i < len; i++)
str[i] = _buffer[(_promptStartPos + i) % kBufferSize];
str[len] = '\0';