Skip to content

Commit

Permalink
Forgot to add prepareFunctions. Fixed Issue 224:segfault with nested …
Browse files Browse the repository at this point in the history
…hashtables reported by David Banks.
  • Loading branch information
higepon committed Sep 6, 2011
1 parent 04aa167 commit b3b68de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/GenericHashTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Object GenericHashTable::copy(bool mutableP)

Object GenericHashTable::keys()
{
prepareFunctions();
Object v = Object::makeVector(map_.size());
int i = 0;
for (GenericMap::const_iterator it = map_.begin(); it != map_.end(); ++it, i++) {
Expand Down
19 changes: 19 additions & 0 deletions tests/misc.scm
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,24 @@
(test-equal '#(1 4 9 16 25 36) old-v1)
(test-equal '#(x 4 9 16 25 36) v1)))

;; Issue 224: segfault with nested hashtables
(let ()
(define-record-type mystruct
(fields id
state))

(define (add-a-struct! ht)
(let* ((sid 53)
(this (make-mystruct sid
(make-hashtable equal-hash equal?))))
(hashtable-set! ht sid this)
(let ((state (mystruct-state this)))
(hashtable-ref state "something" #t) ; this line makes SEGV likely
#f)))

(let ((ht1 (make-eqv-hashtable)))
(add-a-struct! ht1)
(test-equal '#(53) (hashtable-keys ht1))
))
(test-results)

0 comments on commit b3b68de

Please sign in to comment.