shithub: scc

Download patch

ref: 158f03fe23f56bdfd5039cddce176d22f0278601
parent: fd33aabb1f822618a90a1f05ad820f313fff0953
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Jul 2 07:27:10 EDT 2012

Fixed bug in declarator function

Inner loop hadn't buffer overflow test. This patch adds the test,
trnsforming the for (ever) loop into a while.

--- a/decl.c
+++ b/decl.c
@@ -102,9 +102,9 @@
 	register unsigned char *bp, *lim;
 
 	lim = &qlf[NR_DECLARATORS];
-	for (bp = qlf; yytoken == '*' && bp != lim; ++bp) {
+	for (bp = qlf; yytoken == '*' && bp != lim; next()) {
 		*bp++ = PTR;
-		for (;;) {
+		while (bp != lim) {
 			next();
 			switch (yytoken) {
 			case CONST: case VOLATILE: case RESTRICT:
@@ -111,10 +111,10 @@
 				*bp++ = yytoken;
 				break;
 			default:
-				goto next_pointer;
+				goto continue_outer;
 			}
 		}
-	next_pointer: ;
+	continue_outer: ;
 	}
 	if (bp == lim)
 		error("Too much type declarators");