mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
GHI-599: avoid memory leak with default pattern matching and json formatting
This commit is contained in:
parent
e292110bd8
commit
98d1aadb9e
2 changed files with 3 additions and 3 deletions
|
@ -429,7 +429,7 @@ TableVal* Val::GetRecordFields()
|
|||
}
|
||||
|
||||
// This is a static method in this file to avoid including json.hpp in Val.h since it's huge.
|
||||
static ZeekJson BuildJSON(Val* val, bool only_loggable=false, RE_Matcher* re=new RE_Matcher("^_"))
|
||||
static ZeekJson BuildJSON(Val* val, bool only_loggable=false, RE_Matcher* re=nullptr)
|
||||
{
|
||||
// If the value wasn't set, return a nullptr. This will get turned into a 'null' in the json output.
|
||||
if ( ! val )
|
||||
|
@ -562,7 +562,7 @@ static ZeekJson BuildJSON(Val* val, bool only_loggable=false, RE_Matcher* re=new
|
|||
auto field_name = rt->FieldName(i);
|
||||
std::string key_string;
|
||||
|
||||
if ( re->MatchAnywhere(field_name) != 0 )
|
||||
if ( re && re->MatchAnywhere(field_name) != 0 )
|
||||
{
|
||||
StringVal blank("");
|
||||
StringVal fn_val(field_name);
|
||||
|
|
|
@ -348,7 +348,7 @@ public:
|
|||
|
||||
TableVal* GetRecordFields();
|
||||
|
||||
StringVal* ToJSON(bool only_loggable=false, RE_Matcher* re=new RE_Matcher("^_"));
|
||||
StringVal* ToJSON(bool only_loggable=false, RE_Matcher* re=nullptr);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue