commander: Cleanup properly after out-of-mem error

This commit is contained in:
Lorenz Meier 2014-05-15 08:15:59 +02:00
parent ab154c9d3b
commit 4bc06381a9
1 changed files with 14 additions and 0 deletions

View File

@ -121,6 +121,20 @@ int do_mag_calibration(int mavlink_fd)
if (x == NULL || y == NULL || z == NULL) { if (x == NULL || y == NULL || z == NULL) {
mavlink_log_critical(mavlink_fd, "ERROR: out of memory"); mavlink_log_critical(mavlink_fd, "ERROR: out of memory");
/* clean up */
if (x != NULL) {
free(x);
}
if (y != NULL) {
free(y);
}
if (z != NULL) {
free(z);
}
res = ERROR; res = ERROR;
return res; return res;
} }