1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Avoid a use after free in VM assertion

If the thread for the current EC has been killed, don't check
the VM ptr for the EC (which gets it via the thread), as that will
have already been freed.

Fixes [Bug #16907]
This commit is contained in:
Jeremy Evans 2020-08-21 12:52:02 -07:00
parent ea4ccc0992
commit a0273d67d0
Notes: git 2020-08-22 06:52:56 +09:00

View file

@ -1754,6 +1754,7 @@ rb_current_vm(void)
VM_ASSERT(ruby_current_vm_ptr == NULL ||
ruby_current_execution_context_ptr == NULL ||
rb_ec_thread_ptr(GET_EC()) == NULL ||
rb_ec_thread_ptr(GET_EC())->status == THREAD_KILLED ||
rb_ec_vm_ptr(GET_EC()) == ruby_current_vm_ptr);
return ruby_current_vm_ptr;
}