summaryrefslogtreecommitdiff
path: root/srfi
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2008-04-28 18:03:27 +0200
committerLudovic Courtès <ludo@gnu.org>2008-04-28 18:03:27 +0200
commit0fb11ae43259bfa3d07e2da97e644caaff65c477 (patch)
tree66838d241bb68260abb0e92259eb53cfb79071da /srfi
parenta030cb4b16cf9c39fcd8c4ab3b6570d599cd993f (diff)
downloadguile-0fb11ae43259bfa3d07e2da97e644caaff65c477.tar.gz
Fix type-checking of SRFI-1 `partition'.
Diffstat (limited to 'srfi')
-rw-r--r--srfi/ChangeLog5
-rw-r--r--srfi/srfi-1.c11
2 files changed, 14 insertions, 2 deletions
diff --git a/srfi/ChangeLog b/srfi/ChangeLog
index 65ea3e982..1f6c599a8 100644
--- a/srfi/ChangeLog
+++ b/srfi/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-28 Ludovic Courtès <ludo@gnu.org>
+
+ * srfi-1.c (scm_srfi1_partition): Properly type-check LIST.
+ Reported by Julian Graham <joolean@gmail.com>.
+
2008-04-27 Ludovic Courtès <ludo@gnu.org>
* srfi-1.c: Include <config.h>.
diff --git a/srfi/srfi-1.c b/srfi/srfi-1.c
index 2989a25cf..35815b32f 100644
--- a/srfi/srfi-1.c
+++ b/srfi/srfi-1.c
@@ -1667,6 +1667,7 @@ SCM_DEFINE (scm_srfi1_partition, "partition", 2, 0, 0,
/* In this implementation, the output lists don't share memory with
list, because it's probably not worth the effort. */
scm_t_trampoline_1 call = scm_trampoline_1(pred);
+ SCM orig_list = list;
SCM kept = scm_cons(SCM_EOL, SCM_EOL);
SCM kept_tail = kept;
SCM dropped = scm_cons(SCM_EOL, SCM_EOL);
@@ -1675,8 +1676,14 @@ SCM_DEFINE (scm_srfi1_partition, "partition", 2, 0, 0,
SCM_ASSERT(call, pred, 2, FUNC_NAME);
for (; !SCM_NULL_OR_NIL_P (list); list = SCM_CDR(list)) {
- SCM elt = SCM_CAR(list);
- SCM new_tail = scm_cons(SCM_CAR(list), SCM_EOL);
+ SCM elt, new_tail;
+
+ /* Make sure LIST is not a dotted list. */
+ SCM_ASSERT (scm_is_pair (list), orig_list, SCM_ARG2, FUNC_NAME);
+
+ elt = SCM_CAR (list);
+ new_tail = scm_cons (SCM_CAR (list), SCM_EOL);
+
if (scm_is_true (call (pred, elt))) {
SCM_SETCDR(kept_tail, new_tail);
kept_tail = new_tail;