Hi,

It looks like scm_srfi1_partition in srfi/srfi-1.c fails to verify
that it's being called on a real list, and so expressions like:

(partition symbol? '(a b . c))

cause Guile to segfault.  Attached is a patch against HEAD that adds validation.


Regards,
Julian
From 587b22534a40e16adee5f06e70f4d2b633142054 Mon Sep 17 00:00:00 2001
From: Julian Graham <[EMAIL PROTECTED](none)>
Date: Mon, 28 Apr 2008 00:32:47 -0400
Subject: [PATCH] fix segfault in scm_srfi1_partition on non-list input

---
 srfi/ChangeLog |    5 +++++
 srfi/srfi-1.c  |    3 ++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/srfi/ChangeLog b/srfi/ChangeLog
index 65ea3e9..eeedc30 100644
--- a/srfi/ChangeLog
+++ b/srfi/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-28  Julian Graham  <[EMAIL PROTECTED]>
+
+	* srfi-1.c (scm_srfi1_partition): Validate input to avoid
+	segfault when passed something that is not a list.
+
 2008-04-27  Ludovic Courtès  <[EMAIL PROTECTED]>
 
 	* srfi-1.c: Include <config.h>.
diff --git a/srfi/srfi-1.c b/srfi/srfi-1.c
index 2989a25..5036acd 100644
--- a/srfi/srfi-1.c
+++ b/srfi/srfi-1.c
@@ -1673,7 +1673,8 @@ SCM_DEFINE (scm_srfi1_partition, "partition", 2, 0, 0,
   SCM dropped_tail = dropped;
   
   SCM_ASSERT(call, pred, 2, FUNC_NAME);
-  
+  SCM_VALIDATE_LIST (2, list);
+
   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);
-- 
1.5.4.3

Reply via email to