summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-19 01:35:04 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-19 01:35:04 +0000
commit0493b1ce3a43a33bb6298762d67e1a1b4f0a9657 (patch)
tree7553612b4b68a8f6bf2572936af3d40ecf6d11ac /hash.c
parent13155d4df577a2b5fc57c6b16cd92515c2d56870 (diff)
revert r59359, r59356, r59355, r59354
These caused numerous CI failures I haven't been able to reproduce [ruby-core:82102] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index 6ae13ba1b4..c47f21ee9f 100644
--- a/hash.c
+++ b/hash.c
@@ -18,6 +18,7 @@
#include "probes.h"
#include "id.h"
#include "symbol.h"
+#include "gc.h"
#ifdef __APPLE__
# ifdef HAVE_CRT_EXTERNS_H
@@ -1515,13 +1516,33 @@ hash_aset(st_data_t *key, st_data_t *val, struct update_arg *arg, int existing)
return ST_CONTINUE;
}
+static VALUE
+fstring_existing_str(VALUE str)
+{
+ st_data_t fstr;
+ st_table *tbl = rb_vm_fstring_table();
+
+ if (st_lookup(tbl, str, &fstr)) {
+ if (rb_objspace_garbage_object_p(fstr)) {
+ return rb_fstring(str);
+ }
+ else {
+ return (VALUE)fstr;
+ }
+ }
+ else {
+ return Qnil;
+ }
+}
+
static int
hash_aset_str(st_data_t *key, st_data_t *val, struct update_arg *arg, int existing)
{
if (!existing && !RB_OBJ_FROZEN(*key)) {
VALUE k;
- if ((k = rb_fstring_existing(*key)) != Qnil) {
+ if (!RB_OBJ_TAINTED(*key) &&
+ (k = fstring_existing_str(*key)) != Qnil) {
*key = k;
}
else {