summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-27 07:22:56 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-27 07:35:46 -0700
commit80f76773c1940b94a907a76c8d42b60470b33d3d (patch)
treea24049e43d01ba70a17a607937f0ab27ab4292c4
parente89a87a2e8d763fa7eecb923746a972de735a606 (diff)
downloadsubsurface-80f76773c1940b94a907a76c8d42b60470b33d3d.tar.gz
Cleanup: prevent uninitialized pointer
This should never matter as we should never call undoit before redoit. Extra ensurance that we don't access random data. Found by Coverity. Fixes CID 350076 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--desktop-widgets/command_divelist.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/desktop-widgets/command_divelist.cpp b/desktop-widgets/command_divelist.cpp
index 0796c6f5f..6e4ddb427 100644
--- a/desktop-widgets/command_divelist.cpp
+++ b/desktop-widgets/command_divelist.cpp
@@ -383,6 +383,9 @@ AddDive::AddDive(dive *d, bool autogroup, bool newNumber)
d->dc.maxdepth.mm = 0;
fixup_dive(d);
+ // this only matters if undoit were called before redoit
+ currentDive = nullptr;
+
// Get an owning pointer to a moved dive.
OwningDivePtr divePtr(move_dive(d));
divePtr->selected = false; // If we clone a planned dive, it might have been selected.
@@ -453,6 +456,9 @@ ImportDives::ImportDives(struct dive_table *dives, struct trip_table *trips, str
{
setText(tr("import %n dive(s) from %1", "", dives->nr).arg(source));
+ // this only matters if undoit were called before redoit
+ currentDive = nullptr;
+
struct dive_table dives_to_add = { 0 };
struct dive_table dives_to_remove = { 0 };
struct trip_table trips_to_add = { 0 };