Merge remote-tracking branch 'origin/master' into topic/seth/metrics-merge

This commit is contained in:
Seth Hall 2013-04-30 10:18:53 -04:00
commit 7d7d30e1f7
3 changed files with 31 additions and 4 deletions

View file

@ -1,4 +1,9 @@
2.1-397 | 2013-04-29 21:19:00 -0700
* Fixing memory leaks in CompHash implementation. Addresses #987.
(Robin Sommer)
2.1-394 | 2013-04-27 15:02:31 -0700 2.1-394 | 2013-04-27 15:02:31 -0700
* Fixed a bug in the vulnerable software script and added a test. * Fixed a bug in the vulnerable software script and added a test.

View file

@ -1 +1 @@
2.1-394 2.1-397

View file

@ -181,17 +181,25 @@ char* CompositeHash::SingleValHash(int type_check, char* kp0,
Val* key = lv->Index(i); Val* key = lv->Index(i);
if ( ! (kp1 = SingleValHash(type_check, kp1, key->Type(), key, if ( ! (kp1 = SingleValHash(type_check, kp1, key->Type(), key,
false)) ) false)) )
{
Unref(lv);
return 0; return 0;
}
if ( ! v->Type()->IsSet() ) if ( ! v->Type()->IsSet() )
{ {
Val* val = tv->Lookup(key); Val* val = tv->Lookup(key);
if ( ! (kp1 = SingleValHash(type_check, kp1, val->Type(), if ( ! (kp1 = SingleValHash(type_check, kp1, val->Type(),
val, false)) ) val, false)) )
{
Unref(lv);
return 0; return 0;
} }
} }
} }
Unref(lv);
}
break; break;
case TYPE_VECTOR: case TYPE_VECTOR:
@ -454,15 +462,26 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
Val* key = lv->Index(i); Val* key = lv->Index(i);
sz = SingleTypeKeySize(key->Type(), key, type_check, sz, false, sz = SingleTypeKeySize(key->Type(), key, type_check, sz, false,
calc_static_size); calc_static_size);
if ( ! sz ) return 0; if ( ! sz )
{
Unref(lv);
return 0;
}
if ( ! bt->IsSet() ) if ( ! bt->IsSet() )
{ {
Val* val = tv->Lookup(key); Val* val = tv->Lookup(key);
sz = SingleTypeKeySize(val->Type(), val, type_check, sz, sz = SingleTypeKeySize(val->Type(), val, type_check, sz,
false, calc_static_size); false, calc_static_size);
if ( ! sz ) return 0; if ( ! sz )
{
Unref(lv);
return 0;
} }
} }
}
Unref(lv);
break; break;
} }
@ -830,7 +849,10 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0,
} }
for ( int i = 0; i < n; ++i ) for ( int i = 0; i < n; ++i )
{
tv->Assign(keys[i], t->IsSet() ? 0 : values[i]); tv->Assign(keys[i], t->IsSet() ? 0 : values[i]);
Unref(keys[i]);
}
pval = tv; pval = tv;
} }