fix(slider): fix potential division-by-zero (#3656)

This commit is contained in:
Amir Gonnen
2022-09-04 19:15:26 +03:00
committed by GitHub
parent f09c04b935
commit fdc16c5188

View File

@@ -212,9 +212,11 @@ static void lv_slider_event(const lv_obj_class_t * class_p, lv_event_t * e)
/*Make the point relative to the indicator*/ /*Make the point relative to the indicator*/
new_value = p.x - (obj->coords.x1 + bg_left); new_value = p.x - (obj->coords.x1 + bg_left);
} }
if(indic_w) {
new_value = (new_value * range) / indic_w; new_value = (new_value * range) / indic_w;
new_value += slider->bar.min_value; new_value += slider->bar.min_value;
} }
}
else { else {
const lv_coord_t bg_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); const lv_coord_t bg_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
const lv_coord_t bg_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN); const lv_coord_t bg_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);