mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
fix two memory leaks which occured when one used filters.
This commit is contained in:
parent
3b82d69eb3
commit
82a6f3832a
2 changed files with 9 additions and 1 deletions
|
@ -750,7 +750,7 @@ Val* Manager::RecordValToIndexVal(RecordVal *r) {
|
|||
int num_fields = type->NumFields();
|
||||
|
||||
if ( num_fields == 1 && type->FieldDecl(0)->type->Tag() != TYPE_RECORD ) {
|
||||
idxval = r->Lookup(0);
|
||||
idxval = r->LookupWithDefault(0);
|
||||
} else {
|
||||
ListVal *l = new ListVal(TYPE_ANY);
|
||||
for ( int j = 0 ; j < num_fields; j++ ) {
|
||||
|
@ -902,6 +902,7 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals) {
|
|||
|
||||
if ( result == false ) {
|
||||
Unref(predidx);
|
||||
Unref(valval);
|
||||
if ( !updated ) {
|
||||
// throw away. Hence - we quit. And remove the entry from the current dictionary...
|
||||
// (but why should it be in there? assert this).
|
||||
|
@ -956,6 +957,9 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals) {
|
|||
Ref(oldval); // otherwise it is no longer accessible after the assignment
|
||||
filter->tab->Assign(idxval, k, valval);
|
||||
Unref(idxval); // asssign does not consume idxval.
|
||||
if ( predidx != 0 ) {
|
||||
Unref(predidx);
|
||||
}
|
||||
|
||||
filter->currDict->Insert(idxhash, ih);
|
||||
delete idxhash;
|
||||
|
|
|
@ -101,12 +101,16 @@ bool Ascii::DoInit(string path, int arg_mode, int arg_num_fields, const Field* c
|
|||
file = new ifstream(path.c_str());
|
||||
if ( !file->is_open() ) {
|
||||
Error(Fmt("Init: cannot open %s", fname.c_str()));
|
||||
delete(file);
|
||||
file = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ReadHeader(false) == false ) {
|
||||
Error(Fmt("Init: cannot open %s; headers are incorrect", fname.c_str()));
|
||||
file->close();
|
||||
delete(file);
|
||||
file = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue