diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-12-17 08:44:43 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-12-17 09:12:44 -0800 |
commit | 648fec7a3d0b65afdc95c71a638d0f792b93adf2 (patch) | |
tree | 5b3becfa3c4faa2763391678b213f806dc1f149c | |
parent | bd66ab15da4c6b2234d3e094f2c5bc6425907f5d (diff) | |
download | subsurface-648fec7a3d0b65afdc95c71a638d0f792b93adf2.tar.gz |
Cleanup: fix potential uninitialized use of uuid
And make sure we don't create a dive site for an empty location string.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 975e2eb92..b04d8aa89 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -814,15 +814,14 @@ parsed: bool QMLManager::checkLocation(DiveObjectHelper *myDive, struct dive *d, QString location, QString gps) { bool diveChanged = false; - uint32_t uuid; + uint32_t uuid = 0; struct dive_site *ds = get_dive_site_for_dive(d); if (myDive->location() != location) { diveChanged = true; - if (!ds) { + if (!ds) uuid = get_dive_site_uuid_by_name(qPrintable(location), NULL); - if (!uuid) - uuid = create_dive_site(qPrintable(location), d->when); - } + if (!uuid && !location.isEmpty()) + uuid = create_dive_site(qPrintable(location), d->when); d->dive_site_uuid = uuid; } // now make sure that the GPS coordinates match - if the user changed the name but not |