summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-01-05 14:35:53 -0800
committerKaz Kylheku <kaz@kylheku.com>2018-01-05 14:35:53 -0800
commit41a8e915e6684836ba5709cfa9c4a4f85245a136 (patch)
tree58ed5d37629925ea47c6be8fc6f6b3da24c74c37
parent63c6d749f1c8185f4ee88737cb5f53bfb181ee03 (diff)
downloadtxr-41a8e915e6684836ba5709cfa9c4a4f85245a136.tar.gz
txr-41a8e915e6684836ba5709cfa9c4a4f85245a136.tar.bz2
txr-41a8e915e6684836ba5709cfa9c4a4f85245a136.zip
nthcdr: terminate loop if end of list hit.
* lib.c (nthcdr): Terminate loop when nil is hit rather than continuing to count down to zero.
-rw-r--r--lib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 31351fba..f70372fb 100644
--- a/lib.c
+++ b/lib.c
@@ -726,7 +726,7 @@ val nthcdr(val pos, val list)
gc_hint(list);
- while (n-- > 0)
+ while (list && n-- > 0)
list = cdr(list);
return list;