mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
vm.c: add type check before calling mrb_hash_size() on keyword dict
the keyword argument handling code was checking if kdict is not nil before calling mrb_hash_size(), but didn't verify it's actually a hash. malformed bytecode could cause a non-hash value to be stored in the keyword dictionary register, leading to a NULL pointer dereference in h_size(). add mrb_hash_p() check to prevent the crash. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2440,7 +2440,7 @@ RETRY_TRY_BLOCK:
|
||||
kdict = regs[mrb_ci_kidx(ci)];
|
||||
}
|
||||
if (!kd) {
|
||||
if (!mrb_nil_p(kdict) && mrb_hash_size(mrb, kdict) > 0) {
|
||||
if (!mrb_nil_p(kdict) && mrb_hash_p(kdict) && mrb_hash_size(mrb, kdict) > 0) {
|
||||
if (argc < 14) {
|
||||
ci->n++;
|
||||
argc++; /* include kdict in normal arguments */
|
||||
|
||||
Reference in New Issue
Block a user