mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
C++: Add tests for three FPs observed on lgtm.com
This commit is contained in:
@@ -5,3 +5,6 @@
|
||||
| test.cpp:92:2:92:12 | return ... | May return stack-allocated memory from $@. | test.cpp:89:10:89:11 | mc | mc |
|
||||
| test.cpp:112:2:112:12 | return ... | May return stack-allocated memory from $@. | test.cpp:112:9:112:11 | arr | arr |
|
||||
| test.cpp:119:2:119:19 | return ... | May return stack-allocated memory from $@. | test.cpp:119:11:119:13 | arr | arr |
|
||||
| test.cpp:149:3:149:22 | return ... | May return stack-allocated memory from $@. | test.cpp:149:11:149:21 | threadLocal | threadLocal |
|
||||
| test.cpp:155:3:155:18 | return ... | May return stack-allocated memory from $@. | test.cpp:154:19:154:26 | localInt | localInt |
|
||||
| test.cpp:165:3:165:19 | return ... | May return stack-allocated memory from $@. | test.cpp:164:21:164:28 | localBuf | localBuf |
|
||||
|
||||
@@ -143,3 +143,24 @@ char *testArray5()
|
||||
|
||||
return arr; // GOOD
|
||||
}
|
||||
|
||||
int *returnThreadLocal() {
|
||||
thread_local int threadLocal;
|
||||
return &threadLocal; // GOOD [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
int returnDereferenced() {
|
||||
int localInt = 2;
|
||||
int &localRef = localInt;
|
||||
return localRef; // GOOD [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
typedef unsigned long size_t;
|
||||
void *memcpy(void *s1, const void *s2, size_t n);
|
||||
|
||||
char *returnAfterCopy() {
|
||||
char localBuf[] = "Data";
|
||||
static char staticBuf[sizeof(localBuf)];
|
||||
memcpy(staticBuf, localBuf, sizeof(staticBuf));
|
||||
return staticBuf; // GOOD [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user