diff --git a/include/zephyr/shell/shell.h b/include/zephyr/shell/shell.h index 92c3091b6cd..71508f01406 100644 --- a/include/zephyr/shell/shell.h +++ b/include/zephyr/shell/shell.h @@ -17,6 +17,7 @@ #include #include #include +#include #if defined CONFIG_SHELL_GETOPT #include @@ -273,7 +274,8 @@ static inline bool shell_help_is_structured(const char *help) { const struct shell_cmd_help *structured = (const struct shell_cmd_help *)help; - return structured != NULL && structured->magic == SHELL_STRUCTURED_HELP_MAGIC; + return structured != NULL && IS_PTR_ALIGNED(structured, struct shell_cmd_help) && + structured->magic == SHELL_STRUCTURED_HELP_MAGIC; } #if defined(CONFIG_SHELL_HELP) || defined(__DOXYGEN__)