shithub: mc

Download patch

ref: 7eaa7298de834db0a52563f653ca316118fc889d
parent: 82782ab0efcb28ec8263a56e59d560aec49bdc66
author: Ori Bernstein <[email protected]>
date: Tue Jan 3 20:23:59 EST 2012

Remove some random segfaults.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -34,10 +34,12 @@
     Bitset *s;
     int n;
 
-    if (a->cstrs)
+    /* a has no cstrs to satisfy */
+    if (!a->cstrs)
         return 1;
+    /* b satisfies no cstrs; only valid if a requires none */
     if (!b->cstrs)
-        return 0;
+        return bscount(a->cstrs) == 0;
     /* if b->cstrs \ a->cstrs == 0, then all of
      * a's constraints are satisfied. */
     s = dupbs(b->cstrs);
--- a/parse/pickle.c
+++ b/parse/pickle.c
@@ -228,6 +228,10 @@
 {
     int i;
 
+    if (!ty) {
+        wrbyte(fd, Tybad);
+        return;
+    }
     wrbyte(fd, ty->type);
     /* tid is generated; don't write */
     /* cstrs are left out for now: FIXME */
@@ -269,6 +273,8 @@
     int i;
 
     t = rdbyte(fd);
+    if (t == Tybad)
+        return NULL;
     ty = mkty(-1, t);
     /* tid is generated; don't write */
     /* cstrs are left out for now: FIXME */