mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Fix logging filter over-allocation and leak.
The leak could happen in a couple cases where adding a log filter fails: OOM and unsupported field type.
This commit is contained in:
parent
0678468353
commit
f9dc48e573
1 changed files with 5 additions and 1 deletions
|
@ -538,10 +538,11 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
|||
|
||||
filter->fields = (threading::Field**)
|
||||
realloc(filter->fields,
|
||||
sizeof(threading::Field) * ++filter->num_fields);
|
||||
sizeof(threading::Field*) * ++filter->num_fields);
|
||||
|
||||
if ( ! filter->fields )
|
||||
{
|
||||
--filter->num_fields;
|
||||
reporter->Error("out of memory in add_filter");
|
||||
return false;
|
||||
}
|
||||
|
@ -623,7 +624,10 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
|||
include ? include->AsTableVal() : 0,
|
||||
exclude ? exclude->AsTableVal() : 0,
|
||||
"", list<int>()) )
|
||||
{
|
||||
delete filter;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the path for the filter.
|
||||
Val* path_val = fval->Lookup(rtype->FieldOffset("path"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue