From 49bdcc535b1f686abcd110bd5daa64e7d6286bbc Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Mon, 12 Apr 2021 09:10:53 +0300 Subject: App: Mitigations against a possible crash A tab switch may have ended up accessing a NULL pointer. --- src/app.c | 2 +- src/ui/util.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app.c b/src/app.c index d8053315..3107cda3 100644 --- a/src/app.c +++ b/src/app.c @@ -397,7 +397,7 @@ static iBool loadState_App_(iApp *d) { readData_File(f, 4, magic); if (!memcmp(magic, magicTabDocument_App_, 4)) { if (!doc) { - doc = newTab_App(NULL, iTrue); + doc = newTab_App(NULL, iFalse /* no switching */); } if (read8_File(f)) { current = doc; diff --git a/src/ui/util.c b/src/ui/util.c index 754545bd..6fa3e293 100644 --- a/src/ui/util.c +++ b/src/ui/util.c @@ -768,7 +768,7 @@ iLabelWidget *makeMenuButton_LabelWidget(const char *label, const iMenuItem *ite /*-----------------------------------------------------------------------------------------------*/ static iBool isTabPage_Widget_(const iWidget *tabs, const iWidget *page) { - return page->parent == findChild_Widget(tabs, "tabs.pages"); + return page && page->parent == findChild_Widget(tabs, "tabs.pages"); } static iBool tabSwitcher_(iWidget *tabs, const char *cmd) { @@ -787,7 +787,7 @@ static iBool tabSwitcher_(iWidget *tabs, const char *cmd) { } else if (hasParent_Widget(target, tabs)) { /* Some widget on a page. */ - while (!isTabPage_Widget_(tabs, target)) { + while (target && !isTabPage_Widget_(tabs, target)) { target = target->parent; } showTabPage_Widget(tabs, target); -- cgit v1.2.3