Skip to content

Commit 3437cf2

Browse files
committed
C++: only use upperbound if there are no overflows in the guard
1 parent d7afd86 commit 3437cf2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cpp/ql/lib/semmle/code/cpp/rangeanalysis/SimpleRangeAnalysis.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,8 @@ private float getGuardedUpperBound(VariableAccess guardedAccess) {
15491549
// that there is one predecessor, albeit somewhat conservative.
15501550
exists(unique(BasicBlock b | b = def.(BasicBlock).getAPredecessor())) and
15511551
guardedAccess = def.getAUse(v) and
1552-
result = max(float ub | upperBoundFromGuard(guard, guardVa, ub, branch))
1552+
result = max(float ub | upperBoundFromGuard(guard, guardVa, ub, branch)) and
1553+
not exists(Expr e | e = guard.getAChild+() | convertedExprMightOverflow(e))
15531554
)
15541555
}
15551556

0 commit comments

Comments
 (0)