diff --git a/src/asm/lexer.c b/src/asm/lexer.c index e5fd594e..918bf86e 100644 --- a/src/asm/lexer.c +++ b/src/asm/lexer.c @@ -325,8 +325,9 @@ YY_BUFFER_STATE yy_create_buffer(FILE *f) if (pBuffer->nBufferSize >= 2) { size_t pos = pBuffer->nBufferSize - 2; - /* Skip spaces */ - while (pos > 0 && pBuffer->pBufferStart[pos] == ' ') + /* Skip spaces and tabs */ + while (pos > 0 && (pBuffer->pBufferStart[pos] == ' ' + || pBuffer->pBufferStart[pos] == '\t')) pos--; if (pBuffer->pBufferStart[pos] == '\\') diff --git a/test/asm/line-continuation-whitespace.asm b/test/asm/line-continuation-whitespace.asm new file mode 100644 index 00000000..0d00dc8f --- /dev/null +++ b/test/asm/line-continuation-whitespace.asm @@ -0,0 +1,7 @@ +; Test that \ followed by whitespace after a macro invocation at the end of the +; file doesn't cause a segfault. + +bar: MACRO +ENDM + +foo bar baz\ diff --git a/test/asm/line-continuation-whitespace.out b/test/asm/line-continuation-whitespace.out new file mode 100644 index 00000000..e69de29b