summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-08-30 22:18:27 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2018-08-30 22:30:36 +0900
commit50b840c9de7a0a37d42742a53757f2e74447c053 (patch)
tree8e68f5d8457c2cb3af3a0fa7a2cd98380f6aa01a /src
parentf6564dd83e058fee6b264b5ce6db6d868c22d94a (diff)
downloadmruby-50b840c9de7a0a37d42742a53757f2e74447c053.tar.gz
mruby-50b840c9de7a0a37d42742a53757f2e74447c053.zip
Use `mrb_ensure_hash_type()` to check if an operand is a `Hash`; fix #4097
Diffstat (limited to 'src')
-rw-r--r--src/vm.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/vm.c b/src/vm.c
index 98e554607..77d9316d4 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -2720,10 +2720,11 @@ RETRY_TRY_BLOCK:
}
CASE(OP_HASHADD, BB) {
- mrb_value hash = regs[a];
+ mrb_value hash;
int i;
int lim = a+b*2+1;
+ hash = mrb_ensure_hash_type(mrb, regs[a]);
for (i=a+1; i<lim; i+=2) {
mrb_hash_set(mrb, hash, regs[i], regs[i+1]);
}
@@ -2731,7 +2732,9 @@ RETRY_TRY_BLOCK:
NEXT;
}
CASE(OP_HASHCAT, B) {
- mrb_hash_merge(mrb, regs[a], regs[a+1]);
+ mrb_value hash = mrb_ensure_hash_type(mrb, regs[a]);
+
+ mrb_hash_merge(mrb, hash, regs[a+1]);
mrb_gc_arena_restore(mrb, ai);
NEXT;
}