summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authortmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-27 05:28:55 +0000
committertmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-27 05:28:55 +0000
commit0c3b3e9237e8fae4bdfd9e577b1f6275918e1abb (patch)
tree6e17d836d0973f47364e275a7e3894c49f16dddc /hash.c
parent26e969182ba3ccc35e611800ece366b4b106c755 (diff)
* hash.c (hash_aset_str): Use rb_fstring() to de-duplicate hash string
keys. Patch by Eric Wong. [Bug #8998] [ruby-core:57727] * test/ruby/test_hash.rb (class TestHash): test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index 9944b5f..670e7ad 100644
--- a/hash.c
+++ b/hash.c
@@ -1262,7 +1262,9 @@ static int
hash_aset_str(st_data_t *key, st_data_t *val, struct update_arg *arg, int existing)
{
if (!existing) {
- *key = rb_str_new_frozen((VALUE)*key);
+ VALUE str = (VALUE)*key;
+ if (!OBJ_FROZEN(str))
+ *key = rb_fstring((VALUE)*key);
}
return hash_aset(key, val, arg, existing);
}