mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Merge pull request #3206 from geoffw0/newfreefix
C++: Fix `cpp/new-free-mismatch` false positives
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
| test2.cpp:19:3:19:6 | call to free | There is a new/free mismatch between this free and the corresponding $@. | test2.cpp:18:12:18:18 | new | new |
|
||||
| test2.cpp:26:3:26:6 | call to free | There is a new/free mismatch between this free and the corresponding $@. | test2.cpp:25:7:25:13 | new | new |
|
||||
| test2.cpp:51:2:51:5 | call to free | There is a new/free mismatch between this free and the corresponding $@. | test2.cpp:45:18:45:24 | new | new |
|
||||
| test2.cpp:55:2:55:5 | call to free | There is a new/free mismatch between this free and the corresponding $@. | test2.cpp:46:20:46:33 | call to operator new | new |
|
||||
| test2.cpp:57:2:57:18 | delete | There is a malloc/delete mismatch between this delete and the corresponding $@. | test2.cpp:47:21:47:26 | call to malloc | malloc |
|
||||
| test2.cpp:58:2:58:18 | call to operator delete | There is a malloc/delete mismatch between this delete and the corresponding $@. | test2.cpp:47:21:47:26 | call to malloc | malloc |
|
||||
| test.cpp:36:2:36:17 | delete | There is a malloc/delete mismatch between this delete and the corresponding $@. | test.cpp:27:18:27:23 | call to malloc | malloc |
|
||||
| test.cpp:41:2:41:5 | call to free | There is a new/free mismatch between this free and the corresponding $@. | test.cpp:26:7:26:17 | new | new |
|
||||
| test.cpp:68:3:68:11 | delete | There is a malloc/delete mismatch between this delete and the corresponding $@. | test.cpp:64:28:64:33 | call to malloc | malloc |
|
||||
|
||||
@@ -34,3 +34,27 @@ public:
|
||||
};
|
||||
|
||||
MyTest2Class<int> mt2c_i;
|
||||
|
||||
// ---
|
||||
|
||||
void* operator new(size_t);
|
||||
void operator delete(void*);
|
||||
|
||||
void test_operator_new()
|
||||
{
|
||||
void *ptr_new = new int;
|
||||
void *ptr_opnew = ::operator new(sizeof(int));
|
||||
void *ptr_malloc = malloc(sizeof(int));
|
||||
|
||||
delete ptr_new; // GOOD
|
||||
::operator delete(ptr_new); // GOOD
|
||||
free(ptr_new); // BAD
|
||||
|
||||
delete ptr_opnew; // GOOD
|
||||
::operator delete(ptr_opnew); // GOOD
|
||||
free(ptr_opnew); // BAD
|
||||
|
||||
delete ptr_malloc; // BAD
|
||||
::operator delete(ptr_malloc); // BAD
|
||||
free(ptr_malloc); // GOOD
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user