We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4de43e1 commit 7abece4Copy full SHA for 7abece4
cpp/ql/src/Security/CWE/CWE-191/UnsignedDifferenceExpressionComparedZero.c
@@ -1,5 +1,10 @@
1
unsigned limit = get_limit();
2
unsigned total = 0;
3
-while (limit - total > 0) { // wrong: if `total` is greater than `limit` this will underflow and continue executing the loop.
+
4
+while (limit - total > 0) { // BAD: if `total` is greater than `limit` this will underflow and continue executing the loop.
5
total += get_data();
-}
6
+}
7
8
+while (total < limit) { // GOOD: never underflows.
9
+ total += get_data();
10
0 commit comments