all repos — mgba @ 40c6304cf045fe977eb0aaf3e7aa696fe588f000

mGBA Game Boy Advance Emulator

Debugger: Fix reading empty lines
Jeffrey Pfau jeffrey@endrift.com
Sun, 30 Oct 2016 02:50:58 -0700
commit

40c6304cf045fe977eb0aaf3e7aa696fe588f000

parent

e66061ed9ef99b47205e2178673cdecf9cf42c75

1 files changed, 7 insertions(+), 3 deletions(-)

jump to
M src/feature/editline/cli-el-backend.csrc/feature/editline/cli-el-backend.c

@@ -76,9 +76,13 @@ struct CLIDebuggerEditLineBackend* elbe = (struct CLIDebuggerEditLineBackend*) be;

int count; *len = 0; const char* line = el_gets(elbe->elstate, &count); - if (line && count >= 1) { - // Crop off newline - *len = (size_t) count - 1; + if (line) { + if (count > 1) { + // Crop off newline + *len = (size_t) count - 1; + } else if (count == 1) { + *len = 1; + } } return line; }