diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-12-26 13:37:40 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-12-26 13:41:58 -0800 |
commit | 2c8614e43ed6f543f2e644661004a88414a0404e (patch) | |
tree | bf3c0ec8d417ce8156b8d5a0acc1aff576cf5ac3 | |
parent | 652e382e686df5fe0e63e2f2568e820819ab1b08 (diff) | |
download | subsurface-2c8614e43ed6f543f2e644661004a88414a0404e.tar.gz |
Cleanup: check we have dive before dereferencing
Coverity CID: 208341
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index b04d8aa89..20844526d 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -921,6 +921,12 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q QString startpressure, QString endpressure, QString gasmix, QString cylinder, int rating, int visibility) { struct dive *d = get_dive_by_uniq_id(diveId.toInt()); + + if (!d) { + appendTextToLog("cannot commit changes: no dive"); + return; + } + DiveObjectHelper *myDive = new DiveObjectHelper(d); // notes comes back as rich text - let's convert this into plain text @@ -928,10 +934,6 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q doc.setHtml(notes); notes = doc.toPlainText(); - if (!d) { - appendTextToLog("cannot commit changes: no dive"); - return; - } bool diveChanged = false; bool needResort = false; |