Skip to content

Commit

Permalink
Revert "vm.c: add assertions instead of mrb_ensure_hash_type()."
Browse files Browse the repository at this point in the history
This reverts commit 913a0a5.
In some cases, `OP_HASHADD` operand may not be `Hash`. We should check
explicitly in those cases.
  • Loading branch information
matz committed Sep 24, 2021
1 parent ab54ca2 commit c70159b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vm.c
Expand Up @@ -2687,7 +2687,7 @@ mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc)
int lim = a+b*2+1;

hash = regs[a];
mrb_assert(mrb_type(hash) == MRB_TT_HASH);
mrb_ensure_hash_type(mrb, hash);
for (i=a+1; i<lim; i+=2) {
mrb_hash_set(mrb, hash, regs[i], regs[i+1]);
}
Expand All @@ -2697,7 +2697,7 @@ mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc)
CASE(OP_HASHCAT, B) {
mrb_value hash = regs[a];

mrb_assert(mrb_type(hash) == MRB_TT_HASH);
mrb_ensure_hash_type(mrb, hash);
mrb_hash_merge(mrb, hash, regs[a+1]);
mrb_gc_arena_restore(mrb, ai);
NEXT;
Expand Down

0 comments on commit c70159b

Please sign in to comment.