Skip to content

Commit 63f50a9

Browse files
committed
C++: Cleanup the case for possibly-negative unsigned values.
1 parent 9a9f794 commit 63f50a9

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

cpp/ql/lib/semmle/code/cpp/commons/Printf.qll

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,13 +1104,9 @@ class FormatLiteral extends Literal {
11041104
|
11051105
cand =
11061106
max(float cand0 |
1107-
(
1108-
if lower < 0
1109-
then
1110-
// Calculate the value of `(unsigned)lower`.
1111-
cand0 = 2.pow(any(IntType t | t.isUnsigned()).getSize() * 8) + lower
1112-
else cand0 = lower
1113-
)
1107+
// If lower can be negative we use `(unsigned)-1` as the candidate value.
1108+
lower < 0 and
1109+
cand0 = 2.pow(any(IntType t | t.isUnsigned()).getSize() * 8)
11141110
or
11151111
cand0 = upperBound(arg.getFullyConverted())
11161112
)

0 commit comments

Comments
 (0)