shithub: rgbds

Download patch

ref: 67583876684ec56b99d71b7480d6bcfa4d1f4c14
parent: 00de7674af6d7636e99c057f52d1913142454b85
author: Christophe Staïesse <[email protected]>
date: Sun Oct 5 12:36:57 EDT 2014

Add assertion to symFindMacroArg() to debug oob array access

--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -5,6 +5,7 @@
  *
  */
 
+#include <assert.h>
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
@@ -431,6 +432,8 @@
 	if (i == -1)
 		i = MAXMACROARGS + 1;
 
+	assert(i-1 >= 0 &&
+	    i-1 < sizeof(currentmacroargs)/sizeof(*currentmacroargs));
 	return (currentmacroargs[i - 1]);
 }