mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
C++: Add a second example.
This commit is contained in:
17
cpp/ql/src/Critical/DoubleFreeGood2.cpp
Normal file
17
cpp/ql/src/Critical/DoubleFreeGood2.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
void g() {
|
||||
MyTask *task = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
task = new MyTask;
|
||||
|
||||
...
|
||||
|
||||
delete task;
|
||||
task = NULL;
|
||||
|
||||
...
|
||||
} catch (...) {
|
||||
delete task; // GOOD: harmless if task is NULL
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user