mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-16 15:10:35 +08:00
Fix memory leaks identified by cppcheck
* Add `free` / `delete` * Add comment explaining the (presumed) motivation for the use of new instead of allocating on the stack
This commit is contained in:
committed by
Lorenz Meier
parent
5be23060e7
commit
cc1b766824
@@ -89,6 +89,7 @@ int uORBTest::UnitTest::pubsublatency_main()
|
||||
const unsigned maxruns = 1000;
|
||||
unsigned timingsgroup = 0;
|
||||
|
||||
// timings has to be on the heap to keep frame size below 2048 bytes
|
||||
unsigned *timings = new unsigned[maxruns];
|
||||
|
||||
for (unsigned i = 0; i < maxruns; i++) {
|
||||
@@ -129,6 +130,7 @@ int uORBTest::UnitTest::pubsublatency_main()
|
||||
|
||||
if (f == nullptr) {
|
||||
warnx("Error opening file!\n");
|
||||
delete[] timings;
|
||||
return uORB::ERROR;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user