all repos — mgba @ 3ae3b292ee60ca51e625edb754f8619816fad5d0

mGBA Game Boy Advance Emulator

Debugger: Fix boundary conditions in tab completion
Jeffrey Pfau jeffrey@endrift.com
Thu, 23 Apr 2015 23:54:35 -0700
commit

3ae3b292ee60ca51e625edb754f8619816fad5d0

parent

cedfc01a4c75da572eaff1225911572be6448b52

2 files changed, 6 insertions(+), 2 deletions(-)

jump to
M CHANGESCHANGES

@@ -37,6 +37,7 @@ - GBA: Fix hang when loading a savestate if sync to video is enabled

- 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
M src/debugger/cli-debugger.csrc/debugger/cli-debugger.c

@@ -817,7 +817,7 @@ return CC_ERROR;

} 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 @@ }

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;

@@ -842,6 +842,9 @@ if (strncasecmp(name, _debuggerCommands[i].name, len)) {

break; } next = _debuggerCommands[i].name; + } + if (!next) { + return CC_ERROR; } for (; name[len]; ++len) {