mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
fix a couple more leaks. But - still leaking quite a lot with tables.
This commit is contained in:
parent
7a71a74994
commit
b7bbda7244
1 changed files with 14 additions and 5 deletions
|
@ -25,9 +25,15 @@ using threading::Field;
|
||||||
|
|
||||||
struct InputHash {
|
struct InputHash {
|
||||||
hash_t valhash;
|
hash_t valhash;
|
||||||
HashKey* idxkey; // does not need ref or whatever - if it is present here, it is also still present in the TableVal.
|
HashKey* idxkey;
|
||||||
|
~InputHash();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
InputHash::~InputHash() {
|
||||||
|
if ( idxkey )
|
||||||
|
delete idxkey;
|
||||||
|
}
|
||||||
|
|
||||||
declare(PDict, InputHash);
|
declare(PDict, InputHash);
|
||||||
|
|
||||||
class Manager::Filter {
|
class Manager::Filter {
|
||||||
|
@ -821,6 +827,7 @@ int Manager::SendEntryTable(Filter* i, const Value* const *vals) {
|
||||||
// ok, exact duplicate
|
// ok, exact duplicate
|
||||||
filter->lastDict->Remove(idxhash);
|
filter->lastDict->Remove(idxhash);
|
||||||
filter->currDict->Insert(idxhash, h);
|
filter->currDict->Insert(idxhash, h);
|
||||||
|
delete idxhash;
|
||||||
return filter->num_val_fields + filter->num_idx_fields;
|
return filter->num_val_fields + filter->num_idx_fields;
|
||||||
} else {
|
} else {
|
||||||
assert( filter->num_val_fields > 0 );
|
assert( filter->num_val_fields > 0 );
|
||||||
|
@ -855,7 +862,6 @@ int Manager::SendEntryTable(Filter* i, const Value* const *vals) {
|
||||||
//Val* predidx = ListValToRecordVal(idxval->AsListVal(), filter->itype, &startpos);
|
//Val* predidx = ListValToRecordVal(idxval->AsListVal(), filter->itype, &startpos);
|
||||||
predidx = ValueToRecordVal(vals, filter->itype, &startpos);
|
predidx = ValueToRecordVal(vals, filter->itype, &startpos);
|
||||||
//ValueToRecordVal(vals, filter->itype, &startpos);
|
//ValueToRecordVal(vals, filter->itype, &startpos);
|
||||||
Ref(valval);
|
|
||||||
|
|
||||||
if ( updated ) {
|
if ( updated ) {
|
||||||
ev = new EnumVal(BifEnum::Input::EVENT_CHANGED, BifType::Enum::Input::Event);
|
ev = new EnumVal(BifEnum::Input::EVENT_CHANGED, BifType::Enum::Input::Event);
|
||||||
|
@ -865,7 +871,7 @@ int Manager::SendEntryTable(Filter* i, const Value* const *vals) {
|
||||||
|
|
||||||
bool result;
|
bool result;
|
||||||
if ( filter->num_val_fields > 0 ) { // we have values
|
if ( filter->num_val_fields > 0 ) { // we have values
|
||||||
result = CallPred(filter->pred, 3, ev, predidx->Ref(), valval);
|
result = CallPred(filter->pred, 3, ev, predidx->Ref(), valval->Ref());
|
||||||
} else {
|
} else {
|
||||||
// no values
|
// no values
|
||||||
result = CallPred(filter->pred, 2, ev, predidx->Ref());
|
result = CallPred(filter->pred, 2, ev, predidx->Ref());
|
||||||
|
@ -876,10 +882,12 @@ int Manager::SendEntryTable(Filter* i, const Value* const *vals) {
|
||||||
if ( !updated ) {
|
if ( !updated ) {
|
||||||
// throw away. Hence - we quit. And remove the entry from the current dictionary...
|
// throw away. Hence - we quit. And remove the entry from the current dictionary...
|
||||||
delete(filter->currDict->RemoveEntry(idxhash));
|
delete(filter->currDict->RemoveEntry(idxhash));
|
||||||
|
delete idxhash;
|
||||||
return filter->num_val_fields + filter->num_idx_fields;
|
return filter->num_val_fields + filter->num_idx_fields;
|
||||||
} else {
|
} else {
|
||||||
// keep old one
|
// keep old one
|
||||||
filter->currDict->Insert(idxhash, h);
|
filter->currDict->Insert(idxhash, h);
|
||||||
|
delete idxhash;
|
||||||
return filter->num_val_fields + filter->num_idx_fields;
|
return filter->num_val_fields + filter->num_idx_fields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -916,8 +924,10 @@ int Manager::SendEntryTable(Filter* i, const Value* const *vals) {
|
||||||
if ( filter->event && updated )
|
if ( filter->event && updated )
|
||||||
Ref(oldval); // otherwise it is no longer accessible after the assignment
|
Ref(oldval); // otherwise it is no longer accessible after the assignment
|
||||||
filter->tab->Assign(idxval, k, valval);
|
filter->tab->Assign(idxval, k, valval);
|
||||||
|
Unref(idxval); // asssign does not consume idxval.
|
||||||
|
|
||||||
filter->currDict->Insert(idxhash, ih);
|
filter->currDict->Insert(idxhash, ih);
|
||||||
|
delete idxhash;
|
||||||
|
|
||||||
if ( filter->event ) {
|
if ( filter->event ) {
|
||||||
EnumVal* ev;
|
EnumVal* ev;
|
||||||
|
@ -931,12 +941,11 @@ int Manager::SendEntryTable(Filter* i, const Value* const *vals) {
|
||||||
SendEvent(filter->event, 4, filter->description->Ref(), ev, predidx, oldval);
|
SendEvent(filter->event, 4, filter->description->Ref(), ev, predidx, oldval);
|
||||||
} else {
|
} else {
|
||||||
ev = new EnumVal(BifEnum::Input::EVENT_NEW, BifType::Enum::Input::Event);
|
ev = new EnumVal(BifEnum::Input::EVENT_NEW, BifType::Enum::Input::Event);
|
||||||
Ref(valval);
|
|
||||||
if ( filter->num_val_fields == 0 ) {
|
if ( filter->num_val_fields == 0 ) {
|
||||||
Ref(filter->description);
|
Ref(filter->description);
|
||||||
SendEvent(filter->event, 3, filter->description->Ref(), ev, predidx);
|
SendEvent(filter->event, 3, filter->description->Ref(), ev, predidx);
|
||||||
} else {
|
} else {
|
||||||
SendEvent(filter->event, 4, filter->description->Ref(), ev, predidx, valval);
|
SendEvent(filter->event, 4, filter->description->Ref(), ev, predidx, valval->Ref());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue