From 4bc06381a9b44e7da22f21c20082146ad5d29c1d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 15 May 2014 08:15:59 +0200 Subject: commander: Cleanup properly after out-of-mem error --- src/modules/commander/mag_calibration.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/modules/commander/mag_calibration.cpp') 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; } -- cgit v1.2.3