fix potential null pointer access
This commit is contained in:
committed by
Raphael Coeffic
parent
29fcc8d0fd
commit
502b37a19a
@@ -29,11 +29,13 @@ void choicePaintCallback(lv_event_t *e)
|
|||||||
lv_obj_t *target = lv_event_get_target(e);
|
lv_obj_t *target = lv_event_get_target(e);
|
||||||
if (target != nullptr) {
|
if (target != nullptr) {
|
||||||
ChoiceBase *cb = (ChoiceBase*)lv_obj_get_user_data(target);
|
ChoiceBase *cb = (ChoiceBase*)lv_obj_get_user_data(target);
|
||||||
|
if (cb) {
|
||||||
std::string text = cb->getLabelText();
|
std::string text = cb->getLabelText();
|
||||||
lv_label_set_text(cb->label, text.c_str());
|
lv_label_set_text(cb->label, text.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ChoiceBase::ChoiceBase(FormGroup * parent, const rect_t & rect, ChoiceType type, WindowFlags windowFlags):
|
ChoiceBase::ChoiceBase(FormGroup * parent, const rect_t & rect, ChoiceType type, WindowFlags windowFlags):
|
||||||
FormField(parent, rect, windowFlags),
|
FormField(parent, rect, windowFlags),
|
||||||
|
|||||||
+2
@@ -31,6 +31,7 @@ void menuBodyEventCallback(lv_event_t *e)
|
|||||||
if (target != nullptr) {
|
if (target != nullptr) {
|
||||||
long index = (long)lv_event_get_user_data(e);
|
long index = (long)lv_event_get_user_data(e);
|
||||||
MenuBody *mb = (MenuBody *) lv_obj_get_user_data(lv_obj_get_parent(target));
|
MenuBody *mb = (MenuBody *) lv_obj_get_user_data(lv_obj_get_parent(target));
|
||||||
|
if (mb) {
|
||||||
Menu *menu = mb->getParentMenu();
|
Menu *menu = mb->getParentMenu();
|
||||||
if (index < (int)mb->lines.size()) {
|
if (index < (int)mb->lines.size()) {
|
||||||
onKeyPress();
|
onKeyPress();
|
||||||
@@ -49,6 +50,7 @@ void menuBodyEventCallback(lv_event_t *e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MenuBody::MenuBody(Window * parent, const rect_t & rect):
|
MenuBody::MenuBody(Window * parent, const rect_t & rect):
|
||||||
Window(parent, rect, OPAQUE, 0, lv_list_create)
|
Window(parent, rect, OPAQUE, 0, lv_list_create)
|
||||||
|
|||||||
Reference in New Issue
Block a user