altos/lisp: Move stack recursion check after null check
authorKeith Packard <keithp@keithp.com>
Sat, 19 Nov 2016 07:37:44 +0000 (23:37 -0800)
committerKeith Packard <keithp@keithp.com>
Mon, 20 Feb 2017 19:16:52 +0000 (11:16 -0800)
Don't crash when printing null stack this way.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/lisp/ao_lisp_stack.c

index ef07b88a92f4883f78c209190ec7467e36500935..53adf43204bfcafa6622f64d00bcd04e39cc03bb 100644 (file)
@@ -160,11 +160,11 @@ ao_lisp_stack_print(ao_poly poly)
 {
        struct ao_lisp_stack *s = ao_lisp_poly_stack(poly);
 
-       if (s->type & AO_LISP_STACK_PRINT) {
-               printf("[recurse...]");
-               return;
-       }
        while (s) {
+               if (s->type & AO_LISP_STACK_PRINT) {
+                       printf("[recurse...]");
+                       return;
+               }
                s->type |= AO_LISP_STACK_PRINT;
                printf("\t[\n");
                printf("\t\texpr:   "); ao_lisp_poly_print(s->list); printf("\n");