shithub: scc

Download patch

ref: 906fb08c99904b7530efa13b2529a60a2e9c034c
parent: effb6ade9692c5ca019344b501d2c178b5bbaefd
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon May 9 13:06:11 EDT 2016

[cc2-qbe] Fix error in load()

oad() can receive indication of loading a NULL child, so we
have to test that the child is different of NULL (it happens
mainly in ORET, where the expression is optional).

--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
@@ -123,6 +123,8 @@
 	Node *child;
 
 	child = (flags & LOADL) ? np->left : np->right;
+	if (!child)
+		return NULL;
 	tp = &child->type;
 
 	if ((flags & FORCE) || !(child->flags & (ISTMP|ISCONS))) {