Skip to content

Commit

Permalink
ball_rule-prevent-ub-with-unsigned-drqs-175182635 (#4744)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfevold-bbg authored and GitHub Enterprise committed May 15, 2024
1 parent 044df58 commit aa239a6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions groups/bal/ball/ball_rule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ int Rule::hash(const Rule& rule, int size)
BSLS_ASSERT(0 < size);

if (rule.d_hashValue < 0 || rule.d_hashSize != size) {
unsigned int hash =
ManagedAttributeSet::hash(rule.d_attributeSet, size)
+ ThresholdAggregate::hash(rule.d_thresholds, size)
+ bdlb::HashUtil::hash0(rule.d_pattern.c_str(), size);
unsigned int attributeHash =
ManagedAttributeSet::hash(rule.d_attributeSet, size);
unsigned int threshholdHash =
ThresholdAggregate::hash(rule.d_thresholds, size);
unsigned int patternHash =
bdlb::HashUtil::hash0(rule.d_pattern.c_str(), size);
unsigned int hash = attributeHash + threshholdHash + patternHash;
rule.d_hashValue = hash % size;
rule.d_hashSize = size;
}
Expand Down

0 comments on commit aa239a6

Please sign in to comment.