Skip to content

Commit e3249e4

Browse files
committed
polyspace: limit the addition operand instead of casting to long long
1 parent 047e277 commit e3249e4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎lib/suppressions.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,8 @@ std::list<SuppressionList::Suppression> polyspace::Parser::parse(const std::stri
886886
if (rangeValue > 0) {
887887
suppr.type = SuppressionList::Type::block;
888888
suppr.lineBegin = line;
889-
suppr.lineEnd = static_cast<int>(std::min<long long>(std::numeric_limits<int>::max(), static_cast<long long>(line) + rangeValue));
889+
// line can be negative, so limit the lhs; rangeValue > 0 keeps the sum <= INT_MAX
890+
suppr.lineEnd = std::min(line, std::numeric_limits<int>::max() - rangeValue) + rangeValue;
890891
}
891892
else if (polyspaceKind == polyspace::CommentKind::Regular)
892893
suppr.type = SuppressionList::Type::unique;

0 commit comments

Comments
 (0)