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.
This commit is contained in:
Beat Küng
2019-07-18 19:20:44 +02:00
parent aaad71faab
commit b71bae414b
+10 -2
View File
@@ -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;
}