mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-16 18:37:35 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user