diff --git a/src/plugin/ComponentManager.h b/src/plugin/ComponentManager.h index f2485ecad8..3021982040 100644 --- a/src/plugin/ComponentManager.h +++ b/src/plugin/ComponentManager.h @@ -13,6 +13,7 @@ #include "zeek/Type.h" #include "zeek/Val.h" #include "zeek/Var.h" // for add_type() +#include "zeek/ZeekString.h" #include "zeek/module_util.h" #include "zeek/zeekygen/Manager.h" @@ -193,9 +194,7 @@ template const std::string& ComponentManager::GetComponentName(zeek if ( ! tag ) return error; - C* c = Lookup(tag); - - if ( c ) + if ( C* c = Lookup(tag) ) return c->CanonicalName(); reporter->InternalWarning("requested name of unknown component tag %s", tag.AsString().c_str()); @@ -204,7 +203,17 @@ template const std::string& ComponentManager::GetComponentName(zeek template const std::string& ComponentManager::GetComponentName(EnumValPtr val) const { - return GetComponentName(zeek::Tag(std::move(val))); + static const std::string error = ""; + + if ( ! val ) + return error; + + if ( C* c = Lookup(val.get()) ) + return c->CanonicalName(); + + reporter->InternalWarning("requested name of unknown component tag %s", + val->AsString()->CheckString()); + return error; } template zeek::Tag ComponentManager::GetComponentTag(const std::string& name) const