From b25b04a88767ae3dc142076dd3bdeefbaa549690 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 22 Sep 2023 12:36:22 -0400 Subject: Avoid potential null dereferences --- src/gui/GraphBox.cpp | 4 ++++ src/gui/PropertiesWindow.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index 414bbef4..9efba2ee 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -252,6 +252,10 @@ GraphBox::create(App& app, const std::shared_ptr& graph) GraphBox* result = nullptr; const Glib::RefPtr xml = WidgetFactory::create("graph_win"); xml->get_widget_derived("graph_win_vbox", result); + if (!result) { + return {}; + } + result->init_box(app); result->set_graph(graph, nullptr); diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index b51ae37e..042718a0 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -501,10 +501,13 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget) } } else if (type == forge.URI || type == forge.URID) { auto* uri_entry = dynamic_cast(value_widget); - if (uri_entry && URI::is_valid(uri_entry->get_text())) { - return _app->forge().make_urid(URI(uri_entry->get_text())); + if (uri_entry) { + if (URI::is_valid(uri_entry->get_text())) { + return _app->forge().make_urid(URI(uri_entry->get_text())); + } + + _app->log().error("Invalid URI <%1%>\n", uri_entry->get_text()); } - _app->log().error("Invalid URI <%1%>\n", uri_entry->get_text()); } else if (type == forge.String) { auto* entry = dynamic_cast(value_widget); if (entry) { -- cgit v1.2.1