Debugger: Fix boundary conditions in tab completion

This commit is contained in:
Jeffrey Pfau 2015-04-23 23:54:35 -07:00
parent cedfc01a4c
commit 3ae3b292ee
2 changed files with 6 additions and 2 deletions

View File

@ -37,6 +37,7 @@ Bugfixes:
- Debugger: Fix use-after-free in breakpoint clearing code
- Util: Fix resource leak in UTF-8 handling code
- VFS: Fix resource leaks if some allocations fail
- Debugger: Fix boundary conditions in tab completion
Misc:
- Qt: Show multiplayer numbers in window title
- Qt: Handle saving input settings better

View File

@ -817,7 +817,7 @@ static unsigned char _tabComplete(EditLine* elstate, int ch) {
}
const char* commandPtr;
int cmd = 0, len = 0;
size_t cmd = 0, len = 0;
const char* name = 0;
for (commandPtr = li->buffer; commandPtr <= li->cursor; ++commandPtr, ++len) {
for (; (name = _debuggerCommands[cmd].name); ++cmd) {
@ -833,7 +833,7 @@ static unsigned char _tabComplete(EditLine* elstate, int ch) {
if (!name) {
return CC_ERROR;
}
if (_debuggerCommands[cmd + 1].name && name[len - 2] == _debuggerCommands[cmd + 1].name[len - 2]) {
if (_debuggerCommands[cmd + 1].name && strlen(_debuggerCommands[cmd + 1].name) >= len - 1 && name[len - 2] == _debuggerCommands[cmd + 1].name[len - 2]) {
--len;
const char* next = 0;
int i;
@ -843,6 +843,9 @@ static unsigned char _tabComplete(EditLine* elstate, int ch) {
}
next = _debuggerCommands[i].name;
}
if (!next) {
return CC_ERROR;
}
for (; name[len]; ++len) {
if (name[len] != next[len]) {