From 28d06b03543a9c809d22784f9648607a2f369585 Mon Sep 17 00:00:00 2001 From: Paul <35396688+paulh002@users.noreply.github.com> Date: Mon, 20 Dec 2021 15:57:03 +0100 Subject: [PATCH] fix(dropdown): in lv_dropdpwn_get_selected_str handle if there are no options (#2925) * fix lv_dropdown_get_selected_str * fix lv_dropdown_get_selected_str * fix lv_dropdown_get_selected_str --- src/widgets/lv_dropdown.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/widgets/lv_dropdown.c b/src/widgets/lv_dropdown.c index 6b7906ffd..a4382602e 100644 --- a/src/widgets/lv_dropdown.c +++ b/src/widgets/lv_dropdown.c @@ -372,7 +372,15 @@ void lv_dropdown_get_selected_str(const lv_obj_t * obj, char * buf, uint32_t buf uint32_t i; uint32_t line = 0; - size_t txt_len = strlen(dropdown->options); + size_t txt_len; + + if(dropdown->options) { + txt_len = strlen(dropdown->options); + } + else { + buf[0] = '\0'; + return; + } for(i = 0; i < txt_len && line != dropdown->sel_opt_id_orig; i++) { if(dropdown->options[i] == '\n') line++;