altos/scheme: Avoid crashing with non-list in length
authorKeith Packard <keithp@keithp.com>
Sun, 10 Dec 2017 08:02:34 +0000 (00:02 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 10 Dec 2017 08:02:34 +0000 (00:02 -0800)
Use ao_scheme_cons_cdr to fetch the next list element as that returns
NULL for non-cons elements.

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

index 03dad956d6561f59e31f4e79bc3004def0c3e2a9..21ee10cc668abb405ea52db60204053e5a6f01f1 100644 (file)
@@ -195,7 +195,7 @@ ao_scheme_cons_length(struct ao_scheme_cons *cons)
        int     len = 0;
        while (cons) {
                len++;
-               cons = ao_scheme_poly_cons(cons->cdr);
+               cons = ao_scheme_cons_cdr(cons);
        }
        return len;
 }