Making valgrind a bit more happy, and adding code that may or may not

help with #490 and #491.
This commit is contained in:
Robin Sommer 2011-07-10 12:32:33 -07:00
parent 1d20d2a985
commit 5113b100d9
5 changed files with 13 additions and 2 deletions

View file

@ -1028,7 +1028,7 @@ Contents_DNS::Contents_DNS(Connection* conn, bool orig,
Contents_DNS::~Contents_DNS()
{
delete msg_buf;
free(msg_buf);
}
void Contents_DNS::Flush()

View file

@ -1039,6 +1039,11 @@ LogVal* LogMgr::ValToLogVal(Val* val, BroType* ty)
case TYPE_TABLE:
{
ListVal* set = val->AsTableVal()->ConvertToPureList();
if ( ! set )
// ConvertToPureList has reported an internal warning
// already. Just keep going by making something up.
set = new ListVal(TYPE_INT);
lval->val.set_val.size = set->Length();
lval->val.set_val.vals = new LogVal* [lval->val.set_val.size];

View file

@ -2284,7 +2284,10 @@ ListVal* TableVal::ConvertToPureList() const
{
type_list* tl = table_type->Indices()->Types();
if ( tl->length() != 1 )
{
InternalWarning("bad index type in TableVal::ConvertToPureList");
return 0;
}
return ConvertToList((*tl)[0]->Tag());
}

View file

@ -1827,7 +1827,9 @@ BroString* convert_index_to_string(Val* index)
{
ODesc d;
index->Describe(&d);
return new BroString(1, d.TakeBytes(), d.Len());
BroString* s = new BroString(1, d.TakeBytes(), d.Len());
s->SetUseFreeToDelete(1);
return s;
}
%%}

View file

@ -1133,6 +1133,7 @@ uint64 calculate_unique_id()
int rnd;
} unique;
memset(&unique, 0, sizeof(unique)); // Make valgrind happy.
gethostname(unique.hostname, 128);
unique.hostname[sizeof(unique.hostname)-1] = '\0';
gettimeofday(&unique.time, 0);