mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-30 15:00:21 +02:00
Test for deleted weak pairs in hash-for-each.
* libguile/hashtab.c (scm_internal_hash_for_each_handle): Test for deleted weak pairs. * test-suite/tests/hash.test: Add test case.
This commit is contained in:
parent
3aecd36464
commit
c6a2691fff
2 changed files with 15 additions and 1 deletions
|
@ -1464,6 +1464,8 @@ scm_internal_hash_for_each_handle (scm_t_hash_handle_fn fn, void *closure,
|
||||||
handle = SCM_CAR (ls);
|
handle = SCM_CAR (ls);
|
||||||
if (!scm_is_pair (handle))
|
if (!scm_is_pair (handle))
|
||||||
SCM_WRONG_TYPE_ARG (SCM_ARG3, buckets);
|
SCM_WRONG_TYPE_ARG (SCM_ARG3, buckets);
|
||||||
|
if (!SCM_HASHTABLE_WEAK_P (table)
|
||||||
|
|| !SCM_WEAK_PAIR_DELETED_P (handle))
|
||||||
fn (closure, handle);
|
fn (closure, handle);
|
||||||
ls = SCM_CDR (ls);
|
ls = SCM_CDR (ls);
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,3 +347,15 @@
|
||||||
|
|
||||||
(pass-if (equal? 2 (hash-count (lambda (k v)
|
(pass-if (equal? 2 (hash-count (lambda (k v)
|
||||||
(string? v)) table)))))
|
(string? v)) table)))))
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; weak key hash table
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(with-test-prefix "weak key hash table"
|
||||||
|
(pass-if "hash-for-each after gc"
|
||||||
|
(let ((table (make-weak-key-hash-table)))
|
||||||
|
(hashq-set! table (list 'foo) 'bar)
|
||||||
|
(gc)
|
||||||
|
;; Iterate over deleted weak ref without crashing.
|
||||||
|
(unspecified? (hash-for-each (lambda (key value) key) table)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue