From 58ac06682063591fed82df449a30b0b3969be480 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Thu, 10 Nov 2011 22:01:32 +0900 Subject: [PATCH] Adding type check to hash-table-delete!. --- lib/srfi/69/hash.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/srfi/69/hash.c b/lib/srfi/69/hash.c index 869ad89a..d0646843 100644 --- a/lib/srfi/69/hash.c +++ b/lib/srfi/69/hash.c @@ -215,8 +215,12 @@ static sexp sexp_hash_table_cell (sexp ctx, sexp self, sexp_sint_t n, sexp ht, s } static sexp sexp_hash_table_delete (sexp ctx, sexp self, sexp_sint_t n, sexp ht, sexp obj) { - sexp buckets=sexp_hash_table_buckets(ht), eq_fn=sexp_hash_table_eq_fn(ht), - hash_fn=sexp_hash_table_hash_fn(ht), i, p, res; + sexp buckets, eq_fn, hash_fn, i, p, res; + if (!(sexp_pointerp(ht) && strcmp(sexp_string_data(sexp_object_type_name(ctx, ht)), "Hash-Table") == 0)) + return sexp_xtype_exception(ctx, self, "not a Hash-Table", ht); + buckets = sexp_hash_table_buckets(ht); + eq_fn = sexp_hash_table_eq_fn(ht); + hash_fn = sexp_hash_table_hash_fn(ht); i = sexp_get_bucket(ctx, buckets, hash_fn, obj); res = sexp_scan_bucket(ctx, sexp_vector_ref(buckets, i), obj, eq_fn); if (sexp_pairp(res)) {