freeze the hash key (fixes #2945)

This commit is contained in:
Kazuho Oku
2015-09-10 22:24:10 +09:00
parent 1cbbb7e11c
commit 44eb1492be
+5 -3
View File
@@ -104,9 +104,11 @@ static void mrb_hash_modify(mrb_state *mrb, mrb_value hash);
static inline mrb_value
mrb_hash_ht_key(mrb_state *mrb, mrb_value key)
{
if (mrb_string_p(key))
return mrb_str_dup(mrb, key);
else
if (mrb_string_p(key)) {
key = mrb_str_dup(mrb, key);
RSTR_SET_FROZEN_FLAG(mrb_str_ptr(key));
return key;
} else
return key;
}