commit 3913894ebfafc5ed3139e45c309767909f01e81c
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Mon May 9 17:06:11 2016 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Mon May 9 17:06:11 2016 +0200

    [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).

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

Reply via email to