1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 03:30:27 +02:00

* hashtab.c (scm_hash_fn_create_handle_x): If supplied assoc_fn

returns neither a pair nor #f, signal a wrong-type-arg error.
(Thanks to Gregory Marton for reporting this.)

* tests/hash.test: New "hashx" test supplied by Gregory Marton;
prior to today's fix in libguile/hashtab.c, this caused a
segmentation fault.
This commit is contained in:
Neil Jerram 2008-01-18 23:40:49 +00:00
parent 95da7a8613
commit 1978dd74b8
6 changed files with 29 additions and 1 deletions

2
NEWS
View file

@ -15,6 +15,8 @@ backtrace of a stack with a promise object (made by `delay') in it.
** Make `accept' leave guile mode while blocking
** `scm_c_read ()' and `scm_c_write ()' now type-check their port argument
** Fixed a build problem on AIX (use of func_data identifier)
** Fixed a segmentation fault which occurred when hashx-ref or hashx-set! was
called with an associator proc that returns neither a pair nor #f.
* New modules (see the manual for details)

1
THANKS
View file

@ -53,6 +53,7 @@ For fixes or providing information which led to a fix:
Matt Kraai
Jeff Long
Marco Maggi
Gregory Marton
Dan McMahill
Han-Wen Nienhuys
Jan Nieuwenhuizen

View file

@ -1,3 +1,9 @@
2008-01-18 Neil Jerram <neil@ossau.uklinux.net>
* hashtab.c (scm_hash_fn_create_handle_x): If supplied assoc_fn
returns neither a pair nor #f, signal a wrong-type-arg error.
(Thanks to Gregory Marton for reporting this.)
2007-12-29 Neil Jerram <neil@ossau.uklinux.net>
* gc.c (mark_gc_async): Change "func_data" to "fn_data", to avoid

View file

@ -454,8 +454,10 @@ scm_hash_fn_create_handle_x (SCM table, SCM obj, SCM init, unsigned long (*hash_
if (k >= SCM_SIMPLE_VECTOR_LENGTH (buckets))
scm_out_of_range ("hash_fn_create_handle_x", scm_from_ulong (k));
it = assoc_fn (obj, SCM_SIMPLE_VECTOR_REF (buckets, k), closure);
if (scm_is_true (it))
if (scm_is_pair (it))
return it;
else if (scm_is_true (it))
scm_wrong_type_arg_msg (NULL, 0, it, "a pair");
else
{
/* When this is a weak hashtable, running the GC can change it.

View file

@ -1,3 +1,9 @@
2008-01-18 Neil Jerram <neil@ossau.uklinux.net>
* tests/hash.test: New "hashx" test supplied by Gregory Marton;
prior to today's fix in libguile/hashtab.c, this caused a
segmentation fault.
2007-12-29 Neil Jerram <neil@ossau.uklinux.net>
* standalone/test-bad-identifiers: New test.

View file

@ -72,3 +72,14 @@
(hashx-set! hashq assq table 'x 123)
(hashx-remove! hashq assq table 'x)
(null? (hash-map->list noop table)))))
;;;
;;; hashx
;;;
(with-test-prefix "hashx"
(pass-if-exception
"hashx-set! (lambda (k s) 1) (lambda (k al) #t) table 'foo 'bar"
exception:wrong-type-arg
(hashx-set! (lambda (k s) 1) (lambda (k al) #t) (make-hash-table) 'foo 'bar))
)