aboutsummaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-03-07 03:55:54 +0900
committerKoichi Sasada <ko1@atdot.net>2020-03-07 03:55:54 +0900
commitc3584dfacce4d0f2058d8403de6fdce4fd4d686b (patch)
tree4961c7304719e3da35f44ed4a6dcea2dd5a18e3e /hash.c
parent4c019f5a626523e99e2827ed917802e3097c380d (diff)
downloadruby-c3584dfacce4d0f2058d8403de6fdce4fd4d686b.tar.gz
check ar_table first.
RHASH_AR_TABLE_SIZE() has assertion that it is a ar_talbe. The last commit breaks this assumption so check ar_table first.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index ea763c239c..4477ab5853 100644
--- a/hash.c
+++ b/hash.c
@@ -763,11 +763,14 @@ ar_free_and_clear_table(VALUE hash)
static void
ar_try_convert_table(VALUE hash)
{
- st_table *new_tab;
+ if (!RHASH_AR_TABLE_P(hash)) return;
+
const unsigned size = RHASH_AR_TABLE_SIZE(hash);
+
+ st_table *new_tab;
st_index_t i;
- if (!RHASH_AR_TABLE_P(hash) || size < RHASH_AR_TABLE_MAX_SIZE) {
+ if (size < RHASH_AR_TABLE_MAX_SIZE) {
return;
}