mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Fix nested undefined interpolation segfault (#1542)
This commit is contained in:
@@ -797,11 +797,9 @@ static int peek() {
|
|||||||
} else if (c == '{' && !lexerState->disableInterpolation) {
|
} else if (c == '{' && !lexerState->disableInterpolation) {
|
||||||
// If character is an open brace, do symbol interpolation
|
// If character is an open brace, do symbol interpolation
|
||||||
shiftChar();
|
shiftChar();
|
||||||
|
|
||||||
if (auto str = readInterpolation(0); str) {
|
if (auto str = readInterpolation(0); str) {
|
||||||
beginExpansion(str, *str);
|
beginExpansion(str, *str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return peek();
|
return peek();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1201,9 +1199,9 @@ static std::shared_ptr<std::string> readInterpolation(size_t depth) {
|
|||||||
|
|
||||||
if (c == '{') { // Nested interpolation
|
if (c == '{') { // Nested interpolation
|
||||||
shiftChar();
|
shiftChar();
|
||||||
auto str = readInterpolation(depth + 1);
|
if (auto str = readInterpolation(depth + 1); str) {
|
||||||
|
beginExpansion(str, *str);
|
||||||
beginExpansion(str, *str);
|
}
|
||||||
continue; // Restart, reading from the new buffer
|
continue; // Restart, reading from the new buffer
|
||||||
} else if (c == EOF || c == '\r' || c == '\n' || c == '"') {
|
} else if (c == EOF || c == '\r' || c == '\n' || c == '"') {
|
||||||
error("Missing }\n");
|
error("Missing }\n");
|
||||||
|
|||||||
3
test/asm/nested-bad-interpolation.asm
Normal file
3
test/asm/nested-bad-interpolation.asm
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
def p = {{a}}
|
||||||
|
def q = "{b}"
|
||||||
|
def r = "{{c}}"
|
||||||
17
test/asm/nested-bad-interpolation.err
Normal file
17
test/asm/nested-bad-interpolation.err
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
error: nested-bad-interpolation.asm(1):
|
||||||
|
Interpolated symbol "a" is a reserved keyword; add a '#' prefix to use it as a raw symbol
|
||||||
|
error: nested-bad-interpolation.asm(1):
|
||||||
|
Interpolated symbol "" does not exist
|
||||||
|
error: nested-bad-interpolation.asm(1):
|
||||||
|
syntax error, unexpected end of line
|
||||||
|
error: nested-bad-interpolation.asm(2):
|
||||||
|
Interpolated symbol "b" is a reserved keyword; add a '#' prefix to use it as a raw symbol
|
||||||
|
warning: nested-bad-interpolation.asm(2): [-Wobsolete]
|
||||||
|
Treating multi-unit strings as numbers is deprecated
|
||||||
|
error: nested-bad-interpolation.asm(3):
|
||||||
|
Interpolated symbol "c" is a reserved keyword; add a '#' prefix to use it as a raw symbol
|
||||||
|
error: nested-bad-interpolation.asm(3):
|
||||||
|
Interpolated symbol "" does not exist
|
||||||
|
warning: nested-bad-interpolation.asm(3): [-Wobsolete]
|
||||||
|
Treating multi-unit strings as numbers is deprecated
|
||||||
|
error: Assembly aborted (6 errors)!
|
||||||
Reference in New Issue
Block a user