From 34ab5890c5d6f85ab19e3ac23c17dcfe72ee7979 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 7 Dec 2020 23:28:52 +0100 Subject: [PATCH] cc_frm; cc_button_select: Avoid possible crash if no item is selectable Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/6c511e9ccbadf90f84643b13f53435c80c3644d6 Author: Thilo Graf Date: 2020-12-07 (Mon, 07 Dec 2020) --- src/gui/components/cc_button_select.cpp | 6 ++++-- src/gui/components/cc_frm.cpp | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/components/cc_button_select.cpp b/src/gui/components/cc_button_select.cpp index f965e3478..73561ad8c 100644 --- a/src/gui/components/cc_button_select.cpp +++ b/src/gui/components/cc_button_select.cpp @@ -67,8 +67,10 @@ void CCButtonSelect::setSelectedButton( size_t item_id, btn->setButtonTextColor(text_col); } } - if (!btn) - dprintf(DEBUG_NORMAL, "\033[33m[CCButtonSelect]\t[%s - %d], no button object found...\033[0m\n", __func__, __LINE__); + if (!btn){ + dprintf(DEBUG_NORMAL, "\033[31m[CCButtonSelect]\t[%s - %d], ERROR: btn_container size = %d, no button object available...\033[0m\n", __func__, __LINE__, (int)btn_container->size()); + return; + } fb_pixel_t sel_col = fr_col; if (btn_container->size() > 1) diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index c9883257f..394a89534 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -711,6 +711,8 @@ CComponentsItem* CComponentsForm::getSelectedItemObject() const CComponentsItem* ret = NULL; if (sel != -1) ret = static_cast(this->getCCItem(sel)); + else + dprintf(DEBUG_NORMAL, "\033[31m[CComponentsForm]\t[%s - %d], ERROR: no item object found...\033[0m\n", __func__, __LINE__); return ret; }