summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-12-02 07:42:45 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-12-02 07:42:45 -0800
commit9b3459ca129ffe680f8e8c8caeb00167c7180a22 (patch)
treedc823ad21d5bde3b8853cc6c487f7f678f4b0df7 /lib.c
parent6988511ee608ec35c529ed2ee41ad2f324f4534b (diff)
downloadtxr-9b3459ca129ffe680f8e8c8caeb00167c7180a22.tar.gz
txr-9b3459ca129ffe680f8e8c8caeb00167c7180a22.tar.bz2
txr-9b3459ca129ffe680f8e8c8caeb00167c7180a22.zip
tuples: check length argument.
* lib.c (tuples): Check that n argument giving tuple size is a is a positive integer. * tests/012/seql.tl: Test case added.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 0fdc8ef0..7f797bb1 100644
--- a/lib.c
+++ b/lib.c
@@ -3575,8 +3575,12 @@ static val tuples_func(val n, val lcons)
val tuples(val n, val seq, val fill)
{
+ val self = lit("tuples");
seq = nullify(seq);
+ if (!plusp(n) || !integerp(n))
+ uw_throwf(error_s, lit("~a: positive integer required, not ~s"), self, n, nao);
+
if (!seq)
return nil;