Fix some test code related leaks (#10488)

These leaks are not critical but the address-sanitizer complains.
And it's better programming practice anyway.

Signed-off-by: Lukas Woodtli <woodtli.lukas@gmail.com>
This commit is contained in:
Lukas Woodtli 2018-09-16 23:38:50 +02:00 committed by Daniel Agar
parent 3996ab1fc5
commit 3d29e2e76f
2 changed files with 14 additions and 0 deletions

View File

@ -45,6 +45,7 @@
test_class* test = new test_class(); \
bool success = test->run_tests(); \
test->print_results(); \
delete test; \
return success ? 0 : -1; \
} \
}

View File

@ -417,6 +417,7 @@ bool MavlinkFtpTest::_read_test()
&reply); // Payload inside FTP message response
if (!success) {
delete[] bytes;
return false;
}
@ -432,6 +433,7 @@ bool MavlinkFtpTest::_read_test()
&reply); // Payload inside FTP message response
if (!success) {
delete[] bytes;
return false;
}
@ -453,6 +455,7 @@ bool MavlinkFtpTest::_read_test()
&reply); // Payload inside FTP message response
if (!success) {
delete[] bytes;
return false;
}
@ -465,6 +468,7 @@ bool MavlinkFtpTest::_read_test()
&reply); // Payload inside FTP message response
if (!success) {
delete[] bytes;
return false;
}
@ -486,11 +490,15 @@ bool MavlinkFtpTest::_read_test()
&reply); // Payload inside FTP message response
if (!success) {
delete[] bytes;
return false;
}
ut_compare("Didn't get Ack back", reply->opcode, MavlinkFTP::kRspAck);
ut_compare("Incorrect payload size", reply->size, 0);
delete[] bytes;
bytes = nullptr;
}
return true;
@ -531,6 +539,7 @@ bool MavlinkFtpTest::_burst_test()
&reply); // Payload inside FTP message response
if (!success) {
delete[] bytes;
return false;
}
@ -573,11 +582,15 @@ bool MavlinkFtpTest::_burst_test()
&reply); // Payload inside FTP message response
if (!success) {
delete[] bytes;
return false;
}
ut_compare("Didn't get Ack back", reply->opcode, MavlinkFTP::kRspAck);
ut_compare("Incorrect payload size", reply->size, 0);
delete[] bytes;
bytes = nullptr;
}
return true;