]> ocean-lang.org Git - ocean/commitdiff
oceani: handle NULL from parse_oceani()
authorNeilBrown <neil@brown.name>
Mon, 19 Feb 2018 05:54:03 +0000 (16:54 +1100)
committerNeilBrown <neil@brown.name>
Mon, 19 Feb 2018 05:54:03 +0000 (16:54 +1100)
If the parsed finds nothing, it will return a pointer
to a NULL.  We need to be careful not to deref this
in printing, analysis, or execution.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/oceani.mdc

index c38fce52f095cc9279c937bc2b272a5d044e6da0..8e1cb41410623cc4d5fe660528af6a029d7c983e 100644 (file)
@@ -1149,6 +1149,8 @@ also want to know what sort of bracketing to use.
 
        static void print_exec(struct exec *e, int indent, int bracket)
        {
+               if (!e)
+                       return;
                switch (e->type) {
                case Xbinode:
                        print_binode(cast(binode, e), indent, bracket); break;
@@ -2796,6 +2798,8 @@ analysis is a bit more interesting at this level.
                struct binode *b = cast(binode, prog);
                int ok = 1;
 
+               if (!b)
+                       return 0;
                do {
                        ok = 1;
                        propagate_types(b->right, c, &ok, Vnone, 0);
@@ -2826,9 +2830,12 @@ analysis is a bit more interesting at this level.
        static void interp_prog(struct exec *prog, char **argv)
        {
                struct binode *p = cast(binode, prog);
-               struct binode *al = cast(binode, p->left);
+               struct binode *al;
                struct value v;
 
+               if (!prog)
+                       return;
+               al = cast(binode, p->left);
                while (al) {
                        struct var *v = cast(var, al->left);
                        struct value *vl = &v->var->val;