From 3252a6925e040fc3986d1e079c8676f57e75aa9e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 24 Feb 2020 09:15:51 +0100 Subject: [PATCH] LibGUI: Fix silly nullptr dereference in MessageBox::show() Since we take the parent object as a raw pointer, we should handle the case where it's null. --- Libraries/LibGUI/MessageBox.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/LibGUI/MessageBox.cpp b/Libraries/LibGUI/MessageBox.cpp index 736a0f3236..644d770e93 100644 --- a/Libraries/LibGUI/MessageBox.cpp +++ b/Libraries/LibGUI/MessageBox.cpp @@ -35,7 +35,9 @@ namespace GUI { int MessageBox::show(const StringView& text, const StringView& title, Type type, InputType input_type, Core::Object* parent) { - auto box = parent->add(text, title, type, input_type); + auto box = MessageBox::construct(text, title, type, input_type); + if (parent) + parent->add_child(box); return box->exec(); }