shithub: scc

Download patch

ref: 1f5844e2974f89a6f8b78f14aaa026a174f3ef44
parent: 603c00cd96823aedea6d257701d38ed060cfc127
author: Quentin Rameau <quinq@fifth.space>
date: Fri Mar 31 14:07:56 EDT 2017

[cc2] Fix array overflow checks in parser.c

--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -154,7 +154,7 @@
 static Node *
 push(void *elem)
 {
-	if (sp == stack[STACKSIZ])
+	if (sp == &stack[STACKSIZ])
 		error(ESTACKO);
 	return *sp++ = elem;
 }
@@ -387,7 +387,7 @@
 	struct swtch *cur;
 	Node *np = newnode(u.op);
 
-	if (swp == &swtbl[NR_BLOCK+1])
+	if (swp == &swtbl[NR_BLOCK])
 		error(EWTACKO);
 	cur = swp++;
 	cur->nr = 0;