diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-10-26 21:11:39 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-26 19:17:53 -0700 |
commit | c9a39bb08e036c5e18d112dec2abeef1dd889c2c (patch) | |
tree | 51b73dd7ea9793802a8f9e4cbed233fb10a60f8e /qt-models | |
parent | 4f9783ff606081baec1926676bd048e99e00e578 (diff) | |
download | subsurface-c9a39bb08e036c5e18d112dec2abeef1dd889c2c.tar.gz |
Cleanup: avoid resource leak in dive planner model
Found by Coverity. Fixes CID 350121
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/diveplannermodel.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index d2fe5e84a..537bf278f 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -1014,8 +1014,10 @@ void DivePlannerPointsModel::computeVariationsFreeDeco(struct diveplan *original void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, const struct deco_state *previous_ds) { + // nothing to do unless there's an original plan + if (!original_plan) + return; -// bool oldRecalc = setRecalc(false); struct dive *dive = alloc_dive(); copy_dive(&displayed_dive, dive); struct decostop original[60], deeper[60], shallower[60], shorter[60], longer[60]; @@ -1024,10 +1026,6 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, c struct divedatapoint *last_segment; struct deco_state ds = *previous_ds; - if (!original_plan) - return; - - if (in_planner() && prefs.display_variations && decoMode() != RECREATIONAL) { int my_instance = ++instanceCounter; cache_deco_state(&ds, &save); |