diff --git a/CHANGES b/CHANGES index b40fc5320e..aa795ed8e4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ +1.6-dev-1120 | 2011-08-19 19:00:15 -0700 + + * Fix for the CompHash fix. (Robin Sommer) + 1.6-dev-1118 | 2011-08-18 14:11:55 -0700 * Fixing key size calculation in composite hash code. (Robin Sommer) diff --git a/VERSION b/VERSION index 3ae78180ad..89d00dee1a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6-dev-1118 +1.6-dev-1120 diff --git a/src/CompHash.cc b/src/CompHash.cc index 28dfe54ad5..763e5da463 100644 --- a/src/CompHash.cc +++ b/src/CompHash.cc @@ -47,7 +47,7 @@ CompositeHash::CompositeHash(TypeList* composite_type) else { - size = ComputeKeySize(); + size = ComputeKeySize(0, 1, true); if ( size > 0 ) // Fixed size. Make sure what we get is fully aligned. @@ -244,7 +244,7 @@ HashKey* CompositeHash::ComputeHash(const Val* v, int type_check) const if ( ! k ) { - int sz = ComputeKeySize(v, type_check); + int sz = ComputeKeySize(v, type_check, false); if ( sz == 0 ) return 0; @@ -331,7 +331,8 @@ HashKey* CompositeHash::ComputeSingletonHash(const Val* v, int type_check) const } int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v, - int type_check, int sz, bool optional) const + int type_check, int sz, bool optional, + bool calc_static_size) const { InternalTypeTag t = bt->InternalType(); @@ -393,7 +394,8 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v, sz = SingleTypeKeySize(rt->FieldType(i), rv ? rv->Lookup(i) : 0, - type_check, sz, v && optional); + type_check, sz, optional, + calc_static_size); if ( ! sz ) return 0; } @@ -408,7 +410,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v, case TYPE_INTERNAL_STRING: if ( ! v ) - return optional ? sz : 0; + return (optional && ! calc_static_size) ? sz : 0; // Factor in length field. sz = SizeAlign(sz, sizeof(int)); @@ -422,7 +424,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v, return sz; } -int CompositeHash::ComputeKeySize(const Val* v, int type_check) const +int CompositeHash::ComputeKeySize(const Val* v, int type_check, bool calc_static_size) const { const type_list* tl = type->Types(); const val_list* vl = 0; @@ -440,7 +442,7 @@ int CompositeHash::ComputeKeySize(const Val* v, int type_check) const loop_over_list(*tl, i) { sz = SingleTypeKeySize((*tl)[i], v ? v->AsListVal()->Index(i) : 0, - type_check, sz, false); + type_check, sz, false, calc_static_size); if ( ! sz ) return 0; } diff --git a/src/CompHash.h b/src/CompHash.h index e2f87d240b..0e12cbf9a8 100644 --- a/src/CompHash.h +++ b/src/CompHash.h @@ -74,10 +74,12 @@ protected: // the value is computed for the particular list of values. // Returns 0 if the key has an indeterminant size (if v not given), // or if v doesn't match the index type (if given). - int ComputeKeySize(const Val* v = 0, int type_check = 1) const; + int ComputeKeySize(const Val* v, int type_check, + bool calc_static_size) const; int SingleTypeKeySize(BroType*, const Val*, - int type_check, int sz, bool optional) const; + int type_check, int sz, bool optional, + bool calc_static_size) const; TypeList* type; char* key; // space for composite key