mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
variable.c: guard assign_class_name against unresolvable symbol
mrb_sym_name_len() returns NULL when sym is 0, out of range, or references a freed symbol slot. assign_class_name() indexed [0] without checking, so malformed bytecode whose OP_CLASS operand indexed past irep->slen could feed a bogus sym here and crash on NULL[0]. Skip the class-naming side effect when the sym does not resolve to a name. close #6842 Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
+2
-1
@@ -665,7 +665,8 @@ assign_class_name(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
|
||||
{
|
||||
if (namespace_p(mrb_type(v))) {
|
||||
struct RObject *c = mrb_obj_ptr(v);
|
||||
if (obj != c && ISUPPER(mrb_sym_name_len(mrb, sym, NULL)[0])) {
|
||||
const char *name = mrb_sym_name_len(mrb, sym, NULL);
|
||||
if (obj != c && name && ISUPPER(name[0])) {
|
||||
mrb_sym id_classname = MRB_SYM(__classname__);
|
||||
mrb_value o = mrb_obj_iv_get(mrb, c, id_classname);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user