Bugfix: AsString() on an EnumVal will segfault

This likely simply hasn't come up in practice, but we now go the intended route
of producing the textual enum value from the type.
This commit is contained in:
Christian Kreibich 2025-04-10 16:33:26 -07:00
parent c2e039f14d
commit 061a944b07

View file

@ -269,7 +269,8 @@ const std::string& ComponentManager<C>::GetComponentName(EnumValPtr val) const {
if ( C* c = Lookup(val.get()) )
return c->CanonicalName();
reporter->InternalWarning("requested name of unknown component tag %s", val->AsString()->CheckString());
reporter->InternalWarning("requested name of unknown component tag %s",
val->GetType()->AsEnumType()->Lookup(val->Get()));
return error;
}
@ -297,7 +298,8 @@ StringValPtr ComponentManager<C>::GetComponentNameVal(EnumValPtr val) const {
if ( C* c = Lookup(val.get()) )
return c->CanonicalNameVal();
reporter->InternalWarning("requested name of unknown component tag %s", val->AsString()->CheckString());
reporter->InternalWarning("requested name of unknown component tag %s",
val->GetType()->AsEnumType()->Lookup(val->Get()));
return error;
}