ref: c7ed9a275e793e9f6509cc6e900cb5d1c659c6b1
parent: 49aac2961d01a395d60b6eeeb7467021b43498f6
author: Rangi <[email protected]>
date: Wed Mar 31 06:21:04 EDT 2021
Do not expand empty strings Fixes #813
--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -751,6 +751,10 @@
char const *str, size_t size, bool owned,
char const *name)
{
+ /* Do not expand empty strings */
+ if (!size)
+ return;
+
distance += lexerState->expansionOfs; /* Distance argument is relative to read offset! */
/* Increase the total length of all parents, and return the topmost one */
struct Expansion *parent = NULL;
--- /dev/null
+++ b/test/asm/expand-empty-string.asm
@@ -1,0 +1,6 @@
+test: MACRO
+v equs "X"
+X equs "" ; should not be expanded
+\1
+ENDM
+ test v 0
--- /dev/null
+++ b/test/asm/expand-empty-string.err
@@ -1,0 +1,3 @@
+ERROR: expand-empty-string.asm(6) -> expand-empty-string.asm::test(4):
+ syntax error, unexpected number
+error: Assembly aborted (1 error)!
--- /dev/null
+++ b/test/asm/expand-empty-string.simple.err
@@ -1,0 +1,3 @@
+ERROR: expand-empty-string.asm(6) -> expand-empty-string.asm::test(4):
+ syntax error
+error: Assembly aborted (1 error)!