mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
Merge pull request #5569 from geoffw0/memoryfree
C++: Add a test of memory freed queries with strdup.
This commit is contained in:
@@ -10,3 +10,4 @@
|
||||
| test.cpp:89:18:89:23 | call to malloc | This memory is never freed |
|
||||
| test.cpp:156:3:156:26 | new | This memory is never freed |
|
||||
| test.cpp:157:3:157:26 | new[] | This memory is never freed |
|
||||
| test.cpp:167:14:167:19 | call to strdup | This memory is never freed |
|
||||
|
||||
@@ -156,3 +156,15 @@ int overloadedNew() {
|
||||
new(std::nothrow) int(3); // BAD
|
||||
new(std::nothrow) int[2]; // BAD
|
||||
}
|
||||
|
||||
// --- strdup ---
|
||||
|
||||
char *strdup(const char *s1);
|
||||
void output_msg(const char *msg);
|
||||
|
||||
void test_strdup() {
|
||||
char msg[] = "OctoCat";
|
||||
char *cpy = strdup(msg); // BAD
|
||||
|
||||
output_msg(cpy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user