From ceec65a7cda55c7cf3fdf1d6e9d428134b9f1d9d Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Mon, 28 Oct 2024 10:26:10 +0200 Subject: [PATCH] platforms/nuttx/src/px4/common/usr_mcu_version.cpp: Check pointers given as parameters to board_mcu_version Logger may pass NULL pointer for ERRATA, check all the pointers. Signed-off-by: Jukka Laitinen --- platforms/nuttx/src/px4/common/usr_mcu_version.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/platforms/nuttx/src/px4/common/usr_mcu_version.cpp b/platforms/nuttx/src/px4/common/usr_mcu_version.cpp index 058967d1899c..b0631d6f0aa3 100644 --- a/platforms/nuttx/src/px4/common/usr_mcu_version.cpp +++ b/platforms/nuttx/src/px4/common/usr_mcu_version.cpp @@ -111,9 +111,17 @@ int board_mcu_version(char *rev, const char **revstr, const char **errata) unsigned len = sizeof(hw_version_table) / sizeof(hw_version_table[0]); if (hw_version < len) { - *rev = hw_version_table[hw_version].rev; - *revstr = hw_version_table[hw_version].revstr; - *errata = hw_version_table[hw_version].errata; + if (rev) { + *rev = hw_version_table[hw_version].rev; + } + + if (revstr) { + *revstr = hw_version_table[hw_version].revstr; + } + + if (errata) { + *errata = hw_version_table[hw_version].errata; + } } return hw_version;