Merge remote-tracking branch 'origin/topic/timw/599-json-leak'

* origin/topic/timw/599-json-leak:
  GHI-599: avoid memory leak with default pattern matching and json formatting
This commit is contained in:
Jon Siwek 2019-12-16 09:40:01 -08:00
commit 92c2074193
4 changed files with 8 additions and 4 deletions

View file

@ -1,4 +1,8 @@
3.1.0-dev.309 | 2019-12-16 09:40:01 -0800
* GHI-599: avoid memory leak with default pattern matching and json formatting (Tim Wojtulewicz, Corelight)
3.1.0-dev.307 | 2019-12-16 08:20:58 -0800 3.1.0-dev.307 | 2019-12-16 08:20:58 -0800
* Update URL for Malware Hash Registry website (Jon Siwek, Corelight) * Update URL for Malware Hash Registry website (Jon Siwek, Corelight)

View file

@ -1 +1 @@
3.1.0-dev.307 3.1.0-dev.309

View file

@ -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. // 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 the value wasn't set, return a nullptr. This will get turned into a 'null' in the json output.
if ( ! val ) 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); auto field_name = rt->FieldName(i);
std::string key_string; std::string key_string;
if ( re->MatchAnywhere(field_name) != 0 ) if ( re && re->MatchAnywhere(field_name) != 0 )
{ {
StringVal blank(""); StringVal blank("");
StringVal fn_val(field_name); StringVal fn_val(field_name);

View file

@ -348,7 +348,7 @@ public:
TableVal* GetRecordFields(); 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: protected: