mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
Merge branch 'main' into intmultlong
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
| test.cpp:23:8:23:8 | p | Value may be null; it should be checked before dereferencing. |
|
||||
| test.cpp:35:10:35:10 | q | Value may be null; it should be checked before dereferencing. |
|
||||
| test.cpp:43:13:43:13 | q | Value may be null; it should be checked before dereferencing. |
|
||||
| test.cpp:51:17:51:17 | q | Value may be null; it should be checked before dereferencing. |
|
||||
| test.cpp:58:8:58:8 | p | Value may be null; it should be checked before dereferencing. |
|
||||
| test.cpp:67:8:67:8 | p | Value may be null; it should be checked before dereferencing. |
|
||||
@@ -0,0 +1 @@
|
||||
Critical/MissingNullTest.ql
|
||||
71
cpp/ql/test/query-tests/Critical/MissingNullTest/test.cpp
Normal file
71
cpp/ql/test/query-tests/Critical/MissingNullTest/test.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
|
||||
#define NULL (0)
|
||||
|
||||
typedef unsigned long size_t;
|
||||
|
||||
void *memcpy(void *s1, const void *s2, size_t n);
|
||||
void bcopy(const void *source, void *dest, size_t amount);
|
||||
|
||||
void mycopyint(const int *source, int *dest)
|
||||
{
|
||||
*dest = *source;
|
||||
}
|
||||
|
||||
void test1(bool cond)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
{
|
||||
int *p, *q;
|
||||
|
||||
y = *p; // BAD (p is uninitialized and could be 0) [NOT DETECTED]
|
||||
p = NULL;
|
||||
y = *p; // BAD (p is 0)
|
||||
p = &x;
|
||||
y = *p; // GOOD (p points to x)
|
||||
p = q;
|
||||
y = *p; // BAD (p is uninitialized and could be 0) [NOT DETECTED]
|
||||
}
|
||||
|
||||
{
|
||||
int *p = &x;
|
||||
int *q = 0;
|
||||
|
||||
memcpy(p, &y, sizeof(int)); // GOOD (p points to x)
|
||||
memcpy(q, &y, sizeof(int)); // BAD (p is 0)
|
||||
}
|
||||
|
||||
{
|
||||
int *p = &x;
|
||||
int *q = 0;
|
||||
|
||||
bcopy(&y, p, sizeof(int)); // GOOD (p points to x)
|
||||
bcopy(&y, q, sizeof(int)); // BAD (p is 0)
|
||||
}
|
||||
|
||||
{
|
||||
int *p = &x;
|
||||
int *q = 0;
|
||||
|
||||
mycopyint(&y, p); // GOOD (p points to x)
|
||||
mycopyint(&y, q); // BAD (p is 0)
|
||||
}
|
||||
|
||||
{
|
||||
int *p = 0;
|
||||
int *q = &x;
|
||||
|
||||
y = *p; // BAD (p is 0)
|
||||
memcpy(&p, &q, sizeof(p));
|
||||
y = *p; // GOOD (p points to x)
|
||||
}
|
||||
|
||||
{
|
||||
int *p = 0;
|
||||
int *q = &x;
|
||||
|
||||
y = *p; // BAD (p is 0)
|
||||
bcopy(&q, &p, sizeof(p));
|
||||
y = *p; // GOOD (p points to x)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
| test.c:33:3:33:19 | call to not_yet_declared2 | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:32:3:32:3 | not_yet_declared2 | not_yet_declared2 | test.c:33:21:33:22 | ca | ca | file://:0:0:0:0 | int[4] | int[4] | test.c:76:24:76:26 | p#0 | int p#0 |
|
||||
| test.c:33:3:33:19 | call to not_yet_declared2 | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:76:6:76:22 | not_yet_declared2 | not_yet_declared2 | test.c:33:21:33:22 | ca | ca | file://:0:0:0:0 | int[4] | int[4] | test.c:76:24:76:26 | p#0 | int p#0 |
|
||||
| test.c:33:3:33:19 | call to not_yet_declared2 | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:32:3:32:3 | not_yet_declared2 | not_yet_declared2 | test.c:33:21:33:22 | ca | ca | file://:0:0:0:0 | int[4] | int[4] | test.c:76:24:76:26 | (unnamed parameter 0) | int (unnamed parameter 0) |
|
||||
| test.c:33:3:33:19 | call to not_yet_declared2 | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:76:6:76:22 | not_yet_declared2 | not_yet_declared2 | test.c:33:21:33:22 | ca | ca | file://:0:0:0:0 | int[4] | int[4] | test.c:76:24:76:26 | (unnamed parameter 0) | int (unnamed parameter 0) |
|
||||
| test.c:40:3:40:29 | call to declared_empty_defined_with | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:77:6:77:32 | declared_empty_defined_with | declared_empty_defined_with | test.c:40:31:40:32 | & ... | & ... | file://:0:0:0:0 | int * | int * | test.c:77:38:77:38 | x | int x |
|
||||
| test.c:44:3:44:27 | call to not_declared_defined_with | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:80:6:80:30 | not_declared_defined_with | not_declared_defined_with | test.c:44:29:44:31 | 4 | 4 | file://:0:0:0:0 | long long | long long | test.c:80:36:80:36 | x | int x |
|
||||
| test.c:44:3:44:27 | call to not_declared_defined_with | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:80:6:80:30 | not_declared_defined_with | not_declared_defined_with | test.c:44:37:44:42 | 2500000000.0 | 2500000000.0 | file://:0:0:0:0 | float | float | test.c:80:50:80:50 | z | int z |
|
||||
|
||||
Reference in New Issue
Block a user