Skip to content
/ bro Public
forked from zeek/zeek

Commit

Permalink
Fix a reference counting bug in ListVal ctor.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiwek committed Jun 25, 2014
1 parent f7c2c00 commit bfaa082
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,7 @@ void VectorType::Describe(ODesc* d) const
yield_type->Describe(d);
}

BroType* base_type(TypeTag tag)
BroType* base_type_no_ref(TypeTag tag)
{
static BroType* base_types[NUM_TYPES];

Expand All @@ -1707,7 +1707,7 @@ BroType* base_type(TypeTag tag)
base_types[t]->SetLocationInfo(&l);
}

return base_types[t]->Ref();
return base_types[t];
}


Expand Down
8 changes: 7 additions & 1 deletion src/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,13 @@ extern OpaqueType* bloomfilter_type;
extern OpaqueType* x509_opaque_type;

// Returns the BRO basic (non-parameterized) type with the given type.
extern BroType* base_type(TypeTag tag);
// The reference count of the type is not increased.
BroType* base_type_no_ref(TypeTag tag);

// Returns the BRO basic (non-parameterized) type with the given type.
// The caller assumes responsibility for a reference to the type.
inline BroType* base_type(TypeTag tag)
{ return base_type_no_ref(tag)->Ref(); }

// Returns the BRO basic error type.
inline BroType* error_type() { return base_type(TYPE_ERROR); }
Expand Down
2 changes: 1 addition & 1 deletion src/Val.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ bool PatternVal::DoUnserialize(UnserialInfo* info)
}

ListVal::ListVal(TypeTag t)
: Val(new TypeList(t == TYPE_ANY ? 0 : base_type(t)))
: Val(new TypeList(t == TYPE_ANY ? 0 : base_type_no_ref(t)))
{
tag = t;
}
Expand Down

0 comments on commit bfaa082

Please sign in to comment.