mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 19:48:20 +00:00
Fix input framework memory leaks.
Couldn't figure out a test case: gperftools didn't report them (maybe due to threading?), but valgrind did.
This commit is contained in:
parent
e54ea6d7e9
commit
b6e2505202
2 changed files with 11 additions and 11 deletions
|
@ -74,7 +74,6 @@ declare(PDict, InputHash);
|
||||||
class Manager::Stream {
|
class Manager::Stream {
|
||||||
public:
|
public:
|
||||||
string name;
|
string name;
|
||||||
ReaderBackend::ReaderInfo* info;
|
|
||||||
bool removed;
|
bool removed;
|
||||||
|
|
||||||
StreamType stream_type; // to distinguish between event and table streams
|
StreamType stream_type; // to distinguish between event and table streams
|
||||||
|
@ -318,23 +317,23 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
||||||
string source((const char*) bsource->Bytes(), bsource->Len());
|
string source((const char*) bsource->Bytes(), bsource->Len());
|
||||||
Unref(sourceval);
|
Unref(sourceval);
|
||||||
|
|
||||||
ReaderBackend::ReaderInfo* rinfo = new ReaderBackend::ReaderInfo();
|
ReaderBackend::ReaderInfo rinfo;
|
||||||
rinfo->source = copy_string(source.c_str());
|
rinfo.source = copy_string(source.c_str());
|
||||||
rinfo->name = copy_string(name.c_str());
|
rinfo.name = copy_string(name.c_str());
|
||||||
|
|
||||||
EnumVal* mode = description->LookupWithDefault(rtype->FieldOffset("mode"))->AsEnumVal();
|
EnumVal* mode = description->LookupWithDefault(rtype->FieldOffset("mode"))->AsEnumVal();
|
||||||
switch ( mode->InternalInt() )
|
switch ( mode->InternalInt() )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
rinfo->mode = MODE_MANUAL;
|
rinfo.mode = MODE_MANUAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
rinfo->mode = MODE_REREAD;
|
rinfo.mode = MODE_REREAD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
rinfo->mode = MODE_STREAM;
|
rinfo.mode = MODE_STREAM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -357,7 +356,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
||||||
ListVal* index = info->config->RecoverIndex(k);
|
ListVal* index = info->config->RecoverIndex(k);
|
||||||
string key = index->Index(0)->AsString()->CheckString();
|
string key = index->Index(0)->AsString()->CheckString();
|
||||||
string value = v->Value()->AsString()->CheckString();
|
string value = v->Value()->AsString()->CheckString();
|
||||||
rinfo->config.insert(std::make_pair(copy_string(key.c_str()), copy_string(value.c_str())));
|
rinfo.config.insert(std::make_pair(copy_string(key.c_str()), copy_string(value.c_str())));
|
||||||
Unref(index);
|
Unref(index);
|
||||||
delete k;
|
delete k;
|
||||||
}
|
}
|
||||||
|
@ -365,13 +364,12 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReaderFrontend* reader_obj = new ReaderFrontend(*rinfo, reader);
|
ReaderFrontend* reader_obj = new ReaderFrontend(rinfo, reader);
|
||||||
assert(reader_obj);
|
assert(reader_obj);
|
||||||
|
|
||||||
info->reader = reader_obj;
|
info->reader = reader_obj;
|
||||||
info->type = reader->AsEnumVal(); // ref'd by lookupwithdefault
|
info->type = reader->AsEnumVal(); // ref'd by lookupwithdefault
|
||||||
info->name = name;
|
info->name = name;
|
||||||
info->info = rinfo;
|
|
||||||
|
|
||||||
Ref(description);
|
Ref(description);
|
||||||
info->description = description;
|
info->description = description;
|
||||||
|
@ -1356,7 +1354,8 @@ void Manager::SendEndOfData(const Stream *i)
|
||||||
DBG_LOG(DBG_INPUT, "SendEndOfData for stream %s",
|
DBG_LOG(DBG_INPUT, "SendEndOfData for stream %s",
|
||||||
i->name.c_str());
|
i->name.c_str());
|
||||||
#endif
|
#endif
|
||||||
SendEvent(end_of_data, 2, new StringVal(i->name.c_str()), new StringVal(i->info->source));
|
SendEvent(end_of_data, 2, new StringVal(i->name.c_str()),
|
||||||
|
new StringVal(i->reader->Info().source));
|
||||||
|
|
||||||
if ( i->stream_type == ANALYSIS_STREAM )
|
if ( i->stream_type == ANALYSIS_STREAM )
|
||||||
file_mgr->EndOfFile(static_cast<const AnalysisStream*>(i)->file_id);
|
file_mgr->EndOfFile(static_cast<const AnalysisStream*>(i)->file_id);
|
||||||
|
|
|
@ -121,6 +121,7 @@ public:
|
||||||
~ReaderInfo()
|
~ReaderInfo()
|
||||||
{
|
{
|
||||||
delete [] source;
|
delete [] source;
|
||||||
|
delete [] name;
|
||||||
|
|
||||||
for ( config_map::iterator i = config.begin(); i != config.end(); i++ )
|
for ( config_map::iterator i = config.begin(); i != config.end(); i++ )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue