shithub: rgbds

Download patch

ref: f5d3087e9bd13970453d3bf5802fd7ac396d2dba
parent: 5cb6c4af4bdf4f9cbcab531fa85f9a07130f3dd9
author: dbrotz <43593771+dbrotz@users.noreply.github.com>
date: Sun Dec 2 11:16:41 EST 2018

Check if integer constants only contain radix prefix

--- a/src/asm/globlex.c
+++ b/src/asm/globlex.c
@@ -100,7 +100,13 @@
 		break;
 	}
 
-	if (radix == 4) {
+	if (*s == '\0') {
+		/*
+		 * There are no digits after the radix prefix
+		 * (or the string is empty, which shouldn't happen).
+		 */
+		yyerror("Invalid integer constant");
+	} else if (radix == 4) {
 		int32_t c;
 
 		while (*s != '\0') {
--- a/test/asm/divzero-section-bank.out
+++ b/test/asm/divzero-section-bank.out
@@ -1,2 +1,4 @@
 ERROR: divzero-section-bank.asm(1):
+    Invalid integer constant
+ERROR: divzero-section-bank.asm(1):
     Division by zero