From b71bae414b8cebdcf16d74660225caa797700e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Thu, 18 Jul 2019 19:20:44 +0200 Subject: [PATCH] param: fix potential nullptr dereferencing on param import NuttX 7.28 seemed to handle this gracefully, but officially passing NULL results in undefined behavior, and with 7.29 leads to a hardfault. This happens on configs with flash-based params, on the first unsuccessful import attempt. --- src/systemcmds/param/param.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/systemcmds/param/param.cpp b/src/systemcmds/param/param.cpp index f70f4e2211..90def735cb 100644 --- a/src/systemcmds/param/param.cpp +++ b/src/systemcmds/param/param.cpp @@ -395,7 +395,11 @@ do_load(const char *param_file_name) } if (result < 0) { - PX4_ERR("importing from '%s' failed (%i)", param_file_name, result); + if (param_file_name) { + PX4_ERR("importing from '%s' failed (%i)", param_file_name, result); + } else { + PX4_ERR("importing failed (%i)", result); + } return 1; } @@ -421,7 +425,11 @@ do_import(const char *param_file_name) } if (result < 0) { - PX4_ERR("importing from '%s' failed (%i)", param_file_name, result); + if (param_file_name) { + PX4_ERR("importing from '%s' failed (%i)", param_file_name, result); + } else { + PX4_ERR("importing failed (%i)", result); + } return 1; }