mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C++: Add test demonstrating the false positive
This commit is contained in:
@@ -92,3 +92,13 @@ void use_printf(float f, double d)
|
||||
size_t three_chars(unsigned char a, unsigned char b, unsigned char c) {
|
||||
return a * b * c; // at most 16581375
|
||||
}
|
||||
|
||||
void g(unsigned char a, unsigned char b, unsigned char b2, int c) {
|
||||
unsigned long d, e, f, g, h;
|
||||
d = (a + 1) * (b + 1); // GOOD [FALSE POSITIVE]
|
||||
e = (c + 1) * (b + 1); // BAD
|
||||
h = (a + 1) * (b + 1) * (b2 + 1); // GOOD [FALSE POSITIVE]
|
||||
|
||||
f = (a + (a + 1)) * (b + 1); // GOOD [FALSE POSITIVE]
|
||||
g = (c + (a + 1)) * (b + 1); // BAD
|
||||
}
|
||||
@@ -7,3 +7,8 @@
|
||||
| IntMultToLong.c:61:23:61:33 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'long long'. |
|
||||
| IntMultToLong.c:63:23:63:40 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'long long'. |
|
||||
| IntMultToLong.c:75:9:75:13 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'size_t'. |
|
||||
| IntMultToLong.c:98:9:98:25 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'unsigned long'. |
|
||||
| IntMultToLong.c:99:9:99:25 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'unsigned long'. |
|
||||
| IntMultToLong.c:100:9:100:36 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'unsigned long'. |
|
||||
| IntMultToLong.c:102:9:102:31 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'unsigned long'. |
|
||||
| IntMultToLong.c:103:9:103:31 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'unsigned long'. |
|
||||
|
||||
Reference in New Issue
Block a user