shithub: rgbds

Download patch

ref: 2f2f14bf808f5f8fe521666d8e1e48abe77b93ae
parent: c59cb6a828c259292dd0eade7ea23d6112e84f4e
author: Jakub Kądziołka <kuba@kadziolka.net>
date: Sat Mar 2 14:11:53 EST 2019

Fix symbol length checking

When the while loop in `ParseSymbol` stops because of the symbol length,
`copied` will have the value of `MAXSYMLEN`, which is obviously not
greater than `MAXSYMLEN`. Changing the condition to `>=` fixes the
issue.

As a bonus, the correct union field will now be used. It shouldn't
matter, but it's technically UB to use a wrong one.

--- a/src/asm/globlex.c
+++ b/src/asm/globlex.c
@@ -188,7 +188,7 @@
 		}
 	}
 
-	if (copied > MAXSYMLEN)
+	if (copied >= MAXSYMLEN)
 		fatalerror("Symbol too long");
 
 	dest[copied] = 0;
@@ -206,7 +206,7 @@
 		return 0;
 	}
 
-	strcpy(yylval.tzString, dest);
+	strcpy(yylval.tzSym, dest);
 	return 1;
 }