shithub: scc

Download patch

ref: b1210dd43cd074b68872794b5d3ff4c3f818697c
parent: 5407d759369b8652a397ccaf48ff6841d6230148
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Jul 12 11:50:27 EDT 2016

[cc2] Fix case of return without expression

eval is no longer detecting if the input token
is null, and in the case of return this
situation can happen, and it has happening.

--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -329,7 +329,9 @@
 {
 	Node *np = newnode(u.op);
 
-	eval(strtok(NULL, "\t\n"));
+	token = strtok(NULL, "\t\n");
+	if (token)
+		eval(strtok(NULL, "\t\n"));
 	if (!empty())
 		np->left = pop();
 	push(np);