Add `argv` and `argc` check in `OP_ENTER`; fix
`argv` may be retrieved from an array whose `ptr` is `NULL` when it`s
empty.
@@ -1791,8 +1791,11 @@ RETRY_TRY_BLOCK:
kargs = 0;
}
else {
- if (!mrb_hash_p(argv[argc - 1])) {
- if (r) {
+ if (argv && argc > 0 && mrb_hash_p(argv[argc-1])) {
+ kdict = argv[argc-1];
+ mrb_hash_check_kdict(mrb, kdict);
+ }
+ else if (r) {
kdict = mrb_hash_new(mrb);
kargs = 0;
}
@@ -1801,11 +1804,6 @@ RETRY_TRY_BLOCK:
mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));
goto L_RAISE;
}
- }
- else {
- kdict = argv[argc-1];
- }
- mrb_hash_check_kdict(mrb, kdict);
if (MRB_ASPEC_KEY(a) > 0) {
kdict = mrb_hash_dup(mrb, kdict);
}
