mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 12:38:20 +00:00
Memory leak fixes for bad usages of VectorVal ctor.
Many usages of the VectorVal ctor didn't account for the fact that it automatically Ref's the VectorType argument and end up leaking it.
This commit is contained in:
parent
89cb103a2c
commit
7599ac8f31
8 changed files with 100 additions and 15 deletions
12
src/IP.cc
12
src/IP.cc
|
@ -36,13 +36,12 @@ static inline RecordType* hdrType(RecordType*& type, const char* name)
|
|||
|
||||
static VectorVal* BuildOptionsVal(const u_char* data, int len)
|
||||
{
|
||||
VectorVal* vv = new VectorVal(new VectorType(
|
||||
hdrType(ip6_option_type, "ip6_option")->Ref()));
|
||||
VectorVal* vv = new VectorVal(internal_type("ip6_options")->AsVectorType());
|
||||
|
||||
while ( len > 0 )
|
||||
{
|
||||
const struct ip6_opt* opt = (const struct ip6_opt*) data;
|
||||
RecordVal* rv = new RecordVal(ip6_option_type);
|
||||
RecordVal* rv = new RecordVal(hdrType(ip6_option_type, "ip6_option"));
|
||||
rv->Assign(0, new Val(opt->ip6o_type, TYPE_COUNT));
|
||||
|
||||
if ( opt->ip6o_type == 0 )
|
||||
|
@ -87,8 +86,8 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
|
|||
rv->Assign(5, new AddrVal(IPAddr(ip6->ip6_src)));
|
||||
rv->Assign(6, new AddrVal(IPAddr(ip6->ip6_dst)));
|
||||
if ( ! chain )
|
||||
chain = new VectorVal(new VectorType(
|
||||
hdrType(ip6_ext_hdr_type, "ip6_ext_hdr")->Ref()));
|
||||
chain = new VectorVal(
|
||||
internal_type("ip6_ext_hdr_chain")->AsVectorType());
|
||||
rv->Assign(7, chain);
|
||||
}
|
||||
break;
|
||||
|
@ -583,7 +582,8 @@ VectorVal* IPv6_Hdr_Chain::BuildVal() const
|
|||
ip6_mob_type = internal_type("ip6_mobility_hdr")->AsRecordType();
|
||||
}
|
||||
|
||||
VectorVal* rval = new VectorVal(new VectorType(ip6_ext_hdr_type->Ref()));
|
||||
VectorVal* rval = new VectorVal(
|
||||
internal_type("ip6_ext_hdr_chain")->AsVectorType());
|
||||
|
||||
for ( size_t i = 1; i < chain.size(); ++i )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue