From 69b1d7ac94338545fc7e1d27afaf37b6836d8108 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Mon, 14 Dec 2020 20:02:55 -0600 Subject: [PATCH] apps/icon-o-matic: Fix null pointer dereference in export window * Bailing early in SavePanel constructor is pretty bad and creates a bunch of NULL pointers things later try and reference. * HScrollview and VScrollview no longer exist after migrating to using the layout kit. Change-Id: Ia80d68508246f952547fb687e29029304a8ffd1e Reviewed-on: https://review.haiku-os.org/c/haiku/+/3507 Reviewed-by: Alex von Gluck IV Reviewed-by: Adrien Destugues --- src/apps/icon-o-matic/gui/SavePanel.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/apps/icon-o-matic/gui/SavePanel.cpp b/src/apps/icon-o-matic/gui/SavePanel.cpp index 18707e32dc..a277062edc 100644 --- a/src/apps/icon-o-matic/gui/SavePanel.cpp +++ b/src/apps/icon-o-matic/gui/SavePanel.cpp @@ -83,10 +83,8 @@ SavePanel::SavePanel(const char* name, BButton* cancel = dynamic_cast( background->FindView("cancel button")); BView* textview = background->FindView("text view"); - BScrollBar* hscrollbar = dynamic_cast( - background->FindView("HScrollBar")); - if (!cancel || !textview || !hscrollbar) { + if (!cancel || !textview) { printf("SavePanel::SavePanel() - couldn't find necessary controls.\n"); return; } @@ -114,10 +112,6 @@ SavePanel::SavePanel(const char* name, // move up them up the height of the menu field BView *poseview = background->FindView("PoseView"); if (poseview) poseview->ResizeBy(0, -height); - BButton *insert = (BButton *)background->FindView("default button"); - if (hscrollbar) hscrollbar->MoveBy(0, -height); - BScrollBar *vscrollbar = (BScrollBar *)background->FindView("VScrollBar"); - if (vscrollbar) vscrollbar->ResizeBy(0, -height); BView *countvw = (BView *)background->FindView("CountVw"); if (countvw) countvw->MoveBy(0, -height); textview->MoveBy(0, -height); @@ -145,6 +139,8 @@ SavePanel::SavePanel(const char* name, textview->ResizeTo(fSettingsB->Frame().right - fFormatMF->Frame().left, textview->Frame().Height()); + BButton *insert = (BButton *)background->FindView("default button"); + // Make sure the smallest window won't draw the "Settings" button over // anything else float minWindowWidth = textview->Bounds().Width()