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

ruby-changes:53419

From: shyouhei <ko1@a...>
Date: Thu, 8 Nov 2018 18:52:19 +0900 (JST)
Subject: [ruby-changes:53419] shyouhei:r65635 (trunk): st.c: bin might be zero

shyouhei	2018-11-08 18:52:14 +0900 (Thu, 08 Nov 2018)

  New Revision: 65635

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65635

  Log:
    st.c: bin might be zero
    
    When EMPTY_OR_DELETED_BIN_P(bin) is true, it is a wrong idea to
    subtract ENTRY_BASE from it.  Delay doing so until we are sure to be
    safe.

  Modified files:
    trunk/st.c
Index: st.c
===================================================================
--- st.c	(revision 65634)
+++ st.c	(revision 65635)
@@ -2184,13 +2184,13 @@ st_rehash_indexed(st_table *tab) https://github.com/ruby/ruby/blob/trunk/st.c#L2184
         ind = hash_bin(p->hash, tab);
         for(;;) {
             st_index_t bin = get_bin(bins, size_ind, ind);
-            st_table_entry *q = &tab->entries[bin - ENTRY_BASE];
             if (EMPTY_OR_DELETED_BIN_P(bin)) {
                 /* ok, new room */
                 set_bin(bins, size_ind, ind, i + ENTRY_BASE);
                 break;
             }
             else {
+                st_table_entry *q = &tab->entries[bin - ENTRY_BASE];
 		DO_PTR_EQUAL_CHECK(tab, q, p->hash, p->key, eq_p, rebuilt_p);
 		if (EXPECT(rebuilt_p, 0))
 		    return TRUE;

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

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