summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-12 09:10:53 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-12 09:10:53 +0300
commit49bdcc535b1f686abcd110bd5daa64e7d6286bbc (patch)
treec8c40f8528e0a894e7f83c62e1c9465b93c1be9e
parent85c77f3eed5e00a692fb33740fe52bb95f5eb499 (diff)
App: Mitigations against a possible crash
A tab switch may have ended up accessing a NULL pointer.
-rw-r--r--src/app.c2
-rw-r--r--src/ui/util.c4
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) {
397 readData_File(f, 4, magic); 397 readData_File(f, 4, magic);
398 if (!memcmp(magic, magicTabDocument_App_, 4)) { 398 if (!memcmp(magic, magicTabDocument_App_, 4)) {
399 if (!doc) { 399 if (!doc) {
400 doc = newTab_App(NULL, iTrue); 400 doc = newTab_App(NULL, iFalse /* no switching */);
401 } 401 }
402 if (read8_File(f)) { 402 if (read8_File(f)) {
403 current = doc; 403 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
768/*-----------------------------------------------------------------------------------------------*/ 768/*-----------------------------------------------------------------------------------------------*/
769 769
770static iBool isTabPage_Widget_(const iWidget *tabs, const iWidget *page) { 770static iBool isTabPage_Widget_(const iWidget *tabs, const iWidget *page) {
771 return page->parent == findChild_Widget(tabs, "tabs.pages"); 771 return page && page->parent == findChild_Widget(tabs, "tabs.pages");
772} 772}
773 773
774static iBool tabSwitcher_(iWidget *tabs, const char *cmd) { 774static iBool tabSwitcher_(iWidget *tabs, const char *cmd) {
@@ -787,7 +787,7 @@ static iBool tabSwitcher_(iWidget *tabs, const char *cmd) {
787 } 787 }
788 else if (hasParent_Widget(target, tabs)) { 788 else if (hasParent_Widget(target, tabs)) {
789 /* Some widget on a page. */ 789 /* Some widget on a page. */
790 while (!isTabPage_Widget_(tabs, target)) { 790 while (target && !isTabPage_Widget_(tabs, target)) {
791 target = target->parent; 791 target = target->parent;
792 } 792 }
793 showTabPage_Widget(tabs, target); 793 showTabPage_Widget(tabs, target);