shithub: rgbds

Download patch

ref: b83b9825f81e99414df95b000df0fd47d55004aa
parent: d641972cded4339c8763d55115760c58c9b78c18
author: ISSOtm <[email protected]>
date: Mon Aug 17 13:04:23 EDT 2020

Fix _NARG crashing outside of macros

And add a test for it

--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -77,6 +77,10 @@
 
 static int32_t Callback_NARG(void)
 {
+	if (!macro_GetCurrentArgs()) {
+		yyerror("_NARG does not make sense outside of a macro");
+		return 0;
+	}
 	return macro_NbArgs();
 }
 
--- /dev/null
+++ b/test/asm/narg-nosect.asm
@@ -1,0 +1,1 @@
+	PRINTT "{_NARG}\n"
--- /dev/null
+++ b/test/asm/narg-nosect.err
@@ -1,0 +1,3 @@
+ERROR: narg-nosect.asm(1):
+    _NARG does not make sense outside of a macro
+error: Assembly aborted (1 errors)!
--- /dev/null
+++ b/test/asm/narg-nosect.out
@@ -1,0 +1,1 @@
+$0