improve widget_lookup

This commit is contained in:
lixianjing 2022-11-21 18:11:06 +08:00
parent e111e4a7da
commit 32376aa8cb
2 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
2022/11/21
* 完善widget_lookup接口避免访问空指针导致程序崩溃(感谢雨欣提供补丁)
2022/11/20
* 增加lcd_mem的测试用例题(感谢智明提供补丁)

View File

@ -1184,7 +1184,7 @@ static widget_t* widget_lookup_child(widget_t* widget, const char* name) {
return_value_if_fail(widget != NULL && name != NULL, NULL);
WIDGET_FOR_EACH_CHILD_BEGIN(widget, iter, i)
if (iter->name != NULL && tk_str_eq(iter->name, name)) {
if (iter != NULL && iter->name != NULL && tk_str_eq(iter->name, name)) {
return iter;
}
WIDGET_FOR_EACH_CHILD_END()
@ -1219,7 +1219,7 @@ static widget_t* widget_lookup_all(widget_t* widget, const char* name) {
return_value_if_fail(widget != NULL && name != NULL, NULL);
WIDGET_FOR_EACH_CHILD_BEGIN(widget, iter, i)
if (iter->name != NULL && tk_str_eq(iter->name, name)) {
if (iter != NULL && iter->name != NULL && tk_str_eq(iter->name, name)) {
return iter;
} else {
iter = widget_lookup_all(iter, name);