diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-05-15 08:15:59 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-05-15 08:15:59 +0200 |
commit | 4bc06381a9b44e7da22f21c20082146ad5d29c1d (patch) | |
tree | 3d9824612d708aa620c03b58cf9e35ad548969ee /src/modules | |
parent | ab154c9d3bd2f3034382c82b8613613af80287b3 (diff) | |
download | px4-firmware-4bc06381a9b44e7da22f21c20082146ad5d29c1d.tar.gz px4-firmware-4bc06381a9b44e7da22f21c20082146ad5d29c1d.tar.bz2 px4-firmware-4bc06381a9b44e7da22f21c20082146ad5d29c1d.zip |
commander: Cleanup properly after out-of-mem error
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/commander/mag_calibration.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/modules/commander/mag_calibration.cpp b/src/modules/commander/mag_calibration.cpp index 9296db6ed..388820511 100644 --- a/src/modules/commander/mag_calibration.cpp +++ b/src/modules/commander/mag_calibration.cpp @@ -121,6 +121,20 @@ int do_mag_calibration(int mavlink_fd) if (x == NULL || y == NULL || z == NULL) { 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; return res; } |