[ruamoko] Support nil object in obj_error

Segfaulting when trying to produce an error message doesn't help get the
message out. Sure, `obj_error (nil...)` is a bit of an abuse, but it
shouldn't segfault the engine.
This commit is contained in:
Bill Currie 2023-05-27 12:19:04 +09:00
parent 5d9823af30
commit ac42bca98b
1 changed files with 6 additions and 2 deletions

View File

@ -1100,10 +1100,14 @@ obj_verror (probj_t *probj, pr_id_t *object, int code, const char *fmt, int coun
pr_type_t **args)
{
progs_t *pr = probj->pr;
const char *name = "nil";
if (object) {
__auto_type class = &G_STRUCT (pr, pr_class_t, object->class_pointer);
name = PR_GetString (pr, class->name);
}
PR_Sprintf (pr, probj->msg, "obj_verror", fmt, count, args);
PR_RunError (pr, "%s: %s", PR_GetString (pr, class->name), probj->msg->str);
PR_RunError (pr, "%s: %s", name, probj->msg->str);
}
static void