shithub: mc

Download patch

ref: e08b97c2d81aded93b27b0b1812e424c9a2b2043
parent: 0bc3c3660e505983539b62f7f97d880622011d81
author: Ori Bernstein <[email protected]>
date: Mon Dec 19 16:13:12 EST 2011

Fix some random crashes.

    Stubbing in stuff leads to nulls being returned. Don't die
    on them -- assert, or handle them gracefully.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -15,6 +15,7 @@
 /* find the most accurate type mapping */
 static Type *tf(Type *t)
 {
+    assert(t != NULL);
     while (typetab[t->tid])
         t = typetab[t->tid];
     return t;
@@ -211,7 +212,10 @@
 
     t = decltype(n);
     settype(n, t);
-    inferexpr(n->decl.init, NULL);
+    if (n->decl.init) {
+        inferexpr(n->decl.init, NULL);
+        unify(n, type(n), type(n->decl.init));
+    }
 }
 
 static void infernode(Node *n)