diff --git a/src/Func.cc b/src/Func.cc index 5d71be2b0f..f398425216 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -239,11 +239,15 @@ BroFunc::BroFunc(ID* arg_id, Stmt* arg_body, id_list* aggr_inits, : Func(BRO_FUNC) { id = arg_id; - Body b; - b.stmts = AddInits(arg_body, aggr_inits); - b.priority = 0; - bodies.push_back(b); frame_size = arg_frame_size; + + if ( arg_body ) + { + Body b; + b.stmts = AddInits(arg_body, aggr_inits); + b.priority = 0; + bodies.push_back(b); + } } BroFunc::~BroFunc() diff --git a/src/Var.cc b/src/Var.cc index b107156b3a..c9e497d8a5 100644 --- a/src/Var.cc +++ b/src/Var.cc @@ -170,6 +170,16 @@ static void make_var(ID* id, BroType* t, init_class c, Expr* init, } id->UpdateValAttrs(); + + if ( t && t->Tag() == TYPE_FUNC && t->AsFuncType()->IsEvent() ) + { + // For events, add a function value (without any body) here so that + // we can later access the ID even if no implementations have been + // defined. + Func* f = new BroFunc(id, 0, 0, 0); + id->SetVal(new Val(f)); + id->SetConst(); + } }