From aa239a61b36a46813b1492a6a6b26899c7aeaefe Mon Sep 17 00:00:00 2001 From: Jake Fevold Date: Wed, 15 May 2024 16:10:42 -0400 Subject: [PATCH] ball_rule-prevent-ub-with-unsigned-drqs-175182635 (#4744) --- groups/bal/ball/ball_rule.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/groups/bal/ball/ball_rule.cpp b/groups/bal/ball/ball_rule.cpp index d3c32e0331..da1d5f80df 100644 --- a/groups/bal/ball/ball_rule.cpp +++ b/groups/bal/ball/ball_rule.cpp @@ -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; }