[前][次][番号順一覧][スレッド一覧]

ruby-changes:60528

From: Koichi <ko1@a...>
Date: Thu, 26 Mar 2020 23:59:45 +0900 (JST)
Subject: [ruby-changes:60528] 897d4e31b0 (ruby_2_7): check ar_table first.

https://git.ruby-lang.org/ruby.git/commit/?id=897d4e31b0

From 897d4e31b0e5b29405480ed3236bc8c5c6cac3fa Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Sat, 7 Mar 2020 03:55:54 +0900
Subject: 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.

(cherry picked from commit c3584dfacce4d0f2058d8403de6fdce4fd4d686b)

diff --git a/hash.c b/hash.c
index e35aabe..b546f62 100644
--- a/hash.c
+++ b/hash.c
@@ -747,11 +747,14 @@ ar_free_and_clear_table(VALUE hash) https://github.com/ruby/ruby/blob/trunk/hash.c#L747
 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;
     }
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]