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

ruby-changes:58332

From: K.Takata <ko1@a...>
Date: Mon, 21 Oct 2019 11:15:01 +0900 (JST)
Subject: [ruby-changes:58332] 375124be51 (master): st: Do error check only on non-Ruby

https://git.ruby-lang.org/ruby.git/commit/?id=375124be51

From 375124be51c796a53cce9716e83003ef37c7bcf5 Mon Sep 17 00:00:00 2001
From: "K.Takata" <kentkt@c...>
Date: Tue, 30 Jul 2019 12:08:33 +0900
Subject: st: Do error check only on non-Ruby


diff --git a/st.c b/st.c
index 5d3588f..5d0c00c 100644
--- a/st.c
+++ b/st.c
@@ -593,9 +593,15 @@ st_init_table_with_size(const struct st_hash_type *type, st_index_t size) https://github.com/ruby/ruby/blob/trunk/st.c#L593
 #endif
 
     n = get_power2(size);
+#ifndef RUBY
+    if (n < 0)
+        return NULL;
+#endif
     tab = (st_table *) malloc(sizeof (st_table));
+#ifndef RUBY
     if (tab == NULL)
         return NULL;
+#endif
     tab->type = type;
     tab->entry_power = n;
     tab->bin_power = features[n].bin_power;
@@ -604,17 +610,21 @@ st_init_table_with_size(const struct st_hash_type *type, st_index_t size) https://github.com/ruby/ruby/blob/trunk/st.c#L610
         tab->bins = NULL;
     else {
         tab->bins = (st_index_t *) malloc(bins_size(tab));
+#ifndef RUBY
         if (tab->bins == NULL) {
             free(tab);
             return NULL;
         }
+#endif
     }
     tab->entries = (st_table_entry *) malloc(get_allocated_entries(tab)
 					     * sizeof(st_table_entry));
+#ifndef RUBY
     if (tab->entries == NULL) {
         st_free_table(tab);
         return NULL;
     }
+#endif
 #ifdef ST_DEBUG
     memset(tab->entries, ST_INIT_VAL_BYTE,
 	   get_allocated_entries(tab) * sizeof(st_table_entry));
@@ -1312,24 +1322,30 @@ st_copy(st_table *old_tab) https://github.com/ruby/ruby/blob/trunk/st.c#L1322
     st_table *new_tab;
 
     new_tab = (st_table *) malloc(sizeof(st_table));
+#ifndef RUBY
     if (new_tab == NULL)
         return NULL;
+#endif
     *new_tab = *old_tab;
     if (old_tab->bins == NULL)
         new_tab->bins = NULL;
     else {
         new_tab->bins = (st_index_t *) malloc(bins_size(old_tab));
+#ifndef RUBY
         if (new_tab->bins == NULL) {
             free(new_tab);
             return NULL;
         }
+#endif
     }
     new_tab->entries = (st_table_entry *) malloc(get_allocated_entries(old_tab)
 						 * sizeof(st_table_entry));
+#ifndef RUBY
     if (new_tab->entries == NULL) {
         st_free_table(new_tab);
         return NULL;
     }
+#endif
     MEMCPY(new_tab->entries, old_tab->entries, st_table_entry,
 	   get_allocated_entries(old_tab));
     if (old_tab->bins != NULL)
-- 
cgit v0.10.2


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

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