From b60b4ef69d1ae81ace1d4f8ccccdd13aeee01f5a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 22:08:08 -0800 Subject: Fix crash when adding a dive If a dive has no dive_site_uuid we would dereference a NULL pointer and crash. Oops. Signed-off-by: Dirk Hohndel --- qt-ui/simplewidgets.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'qt-ui/simplewidgets.cpp') diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 00f749780..4f050063c 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -666,7 +666,10 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo void LocationInformationWidget::setLocationId(uint32_t uuid) { currentDs = get_dive_site_by_uuid(uuid); - displayed_dive_site = *currentDs; + if (currentDs) + displayed_dive_site = *currentDs; + else + memset(&displayed_dive, 0, sizeof(displayed_dive)); ui.diveSiteName->setText(displayed_dive_site.name); ui.diveSiteDescription->setText(displayed_dive_site.description); ui.diveSiteNotes->setPlainText(displayed_dive_site.notes); -- cgit v1.2.3-70-g09d2