mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fix frame size allocation of alternate event/hook handlers
When the only existing handler doesn't use the full argument list, still have to ensure the full frame is allocated because all arguments get set regardless.
This commit is contained in:
parent
070b28ac05
commit
9243341e8c
3 changed files with 20 additions and 1 deletions
|
@ -449,6 +449,11 @@ void BroFunc::AddBody(IntrusivePtr<Stmt> new_body, id_list* new_inits,
|
|||
if ( new_frame_size > frame_size )
|
||||
frame_size = new_frame_size;
|
||||
|
||||
auto num_args = FType()->Args()->NumFields();
|
||||
|
||||
if ( num_args > static_cast<int>(frame_size) )
|
||||
frame_size = num_args;
|
||||
|
||||
new_body = AddInits(std::move(new_body), new_inits);
|
||||
|
||||
if ( Flavor() == FUNC_FLAVOR_FUNCTION )
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
warning in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.alternate-event-hook-prototypes/alternate-event-hook-prototypes.zeek, line 56 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.alternate-event-hook-prototypes/alternate-event-hook-prototypes.zeek, line 10: use of deprecated prototype (hook(c:count;) : bool and my_hook)
|
||||
warning in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.alternate-event-hook-prototypes/alternate-event-hook-prototypes.zeek, line 68 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.alternate-event-hook-prototypes/alternate-event-hook-prototypes.zeek, line 10: use of deprecated prototype (hook(c:count;) : bool and my_hook)
|
||||
my_hook, infinite, 13
|
||||
my_hook, 13, infinite
|
||||
my_hook, infinite
|
||||
|
@ -9,3 +9,4 @@ my_event, 42, enantiodromia
|
|||
my_event, enantiodromia
|
||||
my_event, 42
|
||||
my_event
|
||||
foo, C
|
||||
|
|
|
@ -13,6 +13,18 @@ global my_hook: hook(s: string);
|
|||
global my_hook: hook(c: count) &deprecated;
|
||||
global my_hook: hook();
|
||||
|
||||
# Required Frame size gets (re)calculated on AddBody, so this "foo" setup is
|
||||
# checking that if the only existing body doesn't use all arguments, the Frame
|
||||
# size is still allocated sufficiently to hold all arguments of the canonical
|
||||
# prototype.
|
||||
global foo: event(a: string, b: string, c: string);
|
||||
global foo: event(c: string);
|
||||
|
||||
event foo(c: string)
|
||||
{
|
||||
print "foo", c;
|
||||
}
|
||||
|
||||
event my_event(s: string, c: count)
|
||||
{
|
||||
print "my_event", s, c;
|
||||
|
@ -67,4 +79,5 @@ event zeek_init()
|
|||
{
|
||||
hook my_hook("infinite", 13);
|
||||
event my_event("enantiodromia", 42);
|
||||
event foo("A", "B", "C");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue