From f11001ff4ee478453714df7ed1efdb8a1aa7fbde Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 26 Jan 2014 07:22:02 -0800 Subject: Don't dereference NULL pointer when adding tanks to a dive plan The code was obviously bogus before. Fixes #429 Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 4ff6894e6..0209b2e1e 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -1429,11 +1429,13 @@ void DivePlannerPointsModel::createTemporaryPlan() cylinder_t *cyl = &stagingDive->cylinder[i]; if (cyl->depth.mm) { dp = create_dp(0, cyl->depth.mm, cyl->gasmix.o2.permille, cyl->gasmix.he.permille, 0); - if (diveplan.dp) + if (diveplan.dp) { dp->next = diveplan.dp->next; - else + diveplan.dp->next = dp; + } else { dp->next = NULL; - diveplan.dp->next = dp; + diveplan.dp = dp; + } } } #if DEBUG_PLAN -- cgit v1.2.3-70-g09d2