Var: Fix null-pointer deref on redefinition of lambdas

Closes #3314
This commit is contained in:
Arne Welzel 2023-09-27 11:08:35 +02:00
parent e22bf8ebb6
commit 8ede22f6ec
11 changed files with 76 additions and 10 deletions

View file

@ -26,8 +26,7 @@
namespace zeek::detail
{
static bool add_prototype(const IDPtr& id, Type* t, std::vector<AttrPtr>* attrs,
const ExprPtr& init)
static bool add_prototype(const IDPtr& id, Type* t, std::vector<AttrPtr>* attrs)
{
if ( ! IsFunc(id->GetType()->Tag()) )
return false;
@ -53,12 +52,6 @@ static bool add_prototype(const IDPtr& id, Type* t, std::vector<AttrPtr>* attrs,
return false;
}
if ( init )
{
init->Error("initialization not allowed during event/hook alternate prototype declaration");
return false;
}
const auto& canon_args = canon_ft->Params();
const auto& alt_args = alt_ft->Params();
@ -221,8 +214,8 @@ static void make_var(const IDPtr& id, TypePtr t, InitClass c, ExprPtr init,
else if ( dt != VAR_REDEF || init || ! attr )
{
if ( IsFunc(id->GetType()->Tag()) )
add_prototype(id, t.get(), attr.get(), init);
if ( IsFunc(id->GetType()->Tag()) && ! init )
add_prototype(id, t.get(), attr.get());
else
id->Error("already defined", init.get());