Button input device: absence of points not detected

Description

indev_button_proc (line 661 of lv_core/lv_indev.c) can badly fail if there is no point(s) array set.

What MCU/Processor/Board and compiler are you using?

ESP32+microPython+LVGL6.1

What do you experience?

If I forget (silly me :blush:) to set the points array for a LV_INDEV_TYPE_BUTTON input device driver, then invariably the program fails with a hard-reset of the microcontroller.

Looking at the C code, if one does not set the points array using lv_indev_set_button_points, then things go badly wrong. Basically lines 663-4 of lv_core/lv_indev.c will try to access inexistant data by dereferencing a NULL pointer (as far as I can tell when an input device is registered, then its btn_points field is set to NULL).

However, looking in the same file at the code to handle groups then one sees (lines 376-80 and 531-35) that the absence of a group is handled gracefully; by a return if NULL.

What do you expect?

A graceful failure. Basically a test wether btn_points==NULL. Copying what is found to handle the case where group==NULL (see lines 376-7, 531-2 of lv_indev.c), one could imagine having the following between lines 662 and 663:

lv_point_t * pts = i->btn_points;
if (pts==NULL) return;

Hi,

It seems reasonable to check it and even add a warning with LV_LOG_WARN. Could you send a Pull request?

I’ll give it a go. I’ll see for tonight or tomorrow morning.

Done. I hope this works as intended.