1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

feat(observer): add null pointer check (#7183)

This commit is contained in:
Paul Vogel 2024-11-06 09:51:54 -06:00 committed by GitHub
parent 8d648181d1
commit 9d80bfa780
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -452,6 +452,9 @@ lv_observer_t * lv_obj_bind_checked(lv_obj_t * obj, lv_subject_t * subject)
#if LV_USE_LABEL
lv_observer_t * lv_label_bind_text(lv_obj_t * obj, lv_subject_t * subject, const char * fmt)
{
LV_ASSERT_NULL(subject);
LV_ASSERT_NULL(obj);
if(fmt == NULL) {
if(subject->type != LV_SUBJECT_TYPE_STRING && subject->type != LV_SUBJECT_TYPE_POINTER) {
LV_LOG_WARN("Incompatible subject type: %d", subject->type);
@ -474,6 +477,9 @@ lv_observer_t * lv_label_bind_text(lv_obj_t * obj, lv_subject_t * subject, const
#if LV_USE_ARC
lv_observer_t * lv_arc_bind_value(lv_obj_t * obj, lv_subject_t * subject)
{
LV_ASSERT_NULL(subject);
LV_ASSERT_NULL(obj);
if(subject->type != LV_SUBJECT_TYPE_INT) {
LV_LOG_WARN("Incompatible subject type: %d", subject->type);
return NULL;
@ -489,6 +495,9 @@ lv_observer_t * lv_arc_bind_value(lv_obj_t * obj, lv_subject_t * subject)
#if LV_USE_SLIDER
lv_observer_t * lv_slider_bind_value(lv_obj_t * obj, lv_subject_t * subject)
{
LV_ASSERT_NULL(subject);
LV_ASSERT_NULL(obj);
if(subject->type != LV_SUBJECT_TYPE_INT) {
LV_LOG_WARN("Incompatible subject type: %d", subject->type);
return NULL;
@ -505,6 +514,9 @@ lv_observer_t * lv_slider_bind_value(lv_obj_t * obj, lv_subject_t * subject)
lv_observer_t * lv_roller_bind_value(lv_obj_t * obj, lv_subject_t * subject)
{
LV_ASSERT_NULL(subject);
LV_ASSERT_NULL(obj);
if(subject->type != LV_SUBJECT_TYPE_INT) {
LV_LOG_WARN("Incompatible subject type: %d", subject->type);
return NULL;
@ -522,6 +534,9 @@ lv_observer_t * lv_roller_bind_value(lv_obj_t * obj, lv_subject_t * subject)
lv_observer_t * lv_dropdown_bind_value(lv_obj_t * obj, lv_subject_t * subject)
{
LV_ASSERT_NULL(subject);
LV_ASSERT_NULL(obj);
if(subject->type != LV_SUBJECT_TYPE_INT) {
LV_LOG_WARN("Incompatible subject type: %d", subject->type);
return NULL;
@ -568,6 +583,9 @@ static void unsubscribe_on_delete_cb(lv_event_t * e)
static lv_observer_t * bind_to_bitfield(lv_subject_t * subject, lv_obj_t * obj, lv_observer_cb_t cb, uint32_t flag,
int32_t ref_value, bool inv)
{
LV_ASSERT_NULL(subject);
LV_ASSERT_NULL(obj);
if(subject->type != LV_SUBJECT_TYPE_INT) {
LV_LOG_WARN("Incompatible subject type: %d", subject->type);
return NULL;