Browse Source

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.
sbg
Beat Küng 6 years ago
parent
commit
b71bae414b
  1. 12
      src/systemcmds/param/param.cpp

12
src/systemcmds/param/param.cpp

@ -395,7 +395,11 @@ do_load(const char *param_file_name) @@ -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) @@ -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;
}

Loading…
Cancel
Save