mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
binpac: Fix two use-after-free bugs.
This commit is contained in:
parent
871541e636
commit
cb524c2fde
2 changed files with 7 additions and 2 deletions
|
@ -16,7 +16,7 @@ public:
|
||||||
|
|
||||||
void append(string m) { msg_ += m; }
|
void append(string m) { msg_ += m; }
|
||||||
string msg() const { return msg_; }
|
string msg() const { return msg_; }
|
||||||
const char* c_msg() const { return msg().c_str(); }
|
const char* c_msg() const { return msg_.c_str(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
string msg_;
|
string msg_;
|
||||||
|
|
|
@ -23,6 +23,8 @@ Field::~Field()
|
||||||
|
|
||||||
void Field::AddAttr(AttrList* attrs)
|
void Field::AddAttr(AttrList* attrs)
|
||||||
{
|
{
|
||||||
|
bool delete_attrs = false;
|
||||||
|
|
||||||
if ( ! attrs_ )
|
if ( ! attrs_ )
|
||||||
{
|
{
|
||||||
attrs_ = attrs;
|
attrs_ = attrs;
|
||||||
|
@ -30,11 +32,14 @@ void Field::AddAttr(AttrList* attrs)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
attrs_->insert(attrs_->end(), attrs->begin(), attrs->end());
|
attrs_->insert(attrs_->end(), attrs->begin(), attrs->end());
|
||||||
delete attrs;
|
delete_attrs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(i, AttrList, attrs)
|
foreach(i, AttrList, attrs)
|
||||||
ProcessAttr(*i);
|
ProcessAttr(*i);
|
||||||
|
|
||||||
|
if ( delete_attrs )
|
||||||
|
delete attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Field::ProcessAttr(Attr *a)
|
void Field::ProcessAttr(Attr *a)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue