boot: menu: Do not dereference pointer if pointer is NULL

scene_obj_find can return NULL but this is not checked for before
the return is dereferenced. Add a NULL check.

This issue was found by Smatch.

Also add a NULL check for str.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Andrew Goodbody
2025-07-02 10:24:16 +01:00
committed by Tom Rini
parent c3b43eeaea
commit 074e059527

View File

@@ -571,13 +571,14 @@ int scene_menu_display(struct scene_obj_menu *menu)
return log_msg_ret("txt", -EINVAL);
str = expo_get_str(exp, txt->gen.str_id);
printf("%s\n\n", str);
printf("%s\n\n", str ? str : "");
}
if (list_empty(&menu->item_head))
return 0;
pointer = scene_obj_find(scn, menu->pointer_id, SCENEOBJT_TEXT);
if (pointer)
pstr = expo_get_str(scn->expo, pointer->gen.str_id);
list_for_each_entry(item, &menu->item_head, sibling) {