summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-06 22:38:01 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-06 22:40:18 -0700
commit03bc40194d264226d1e666dab8a5e34a697c13fa (patch)
treec87f247fb55b4a3ff720f7041cca8f4839b60b7a
parent7297c5991be64003802edc064c3f456ce9152a0b (diff)
downloadsubsurface-03bc40194d264226d1e666dab8a5e34a697c13fa.tar.gz
core: don't crash on merge of non-existing dive site
While we shouldn't have a dive that references a dive site that doesn't exist, if we do, we shouldn't crash. And a dive site that doesn't exist is most definitely 'empty'. Reported-by: Benjamin Fogel <nystire@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--core/divesite.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/divesite.c b/core/divesite.c
index e3fb05966..04f6520b8 100644
--- a/core/divesite.c
+++ b/core/divesite.c
@@ -240,7 +240,8 @@ uint32_t create_dive_site_with_gps(const char *name, degrees_t latitude, degrees
/* a uuid is always present - but if all the other fields are empty, the dive site is pointless */
bool dive_site_is_empty(struct dive_site *ds)
{
- return empty_string(ds->name) &&
+ return !ds ||
+ empty_string(ds->name) &&
empty_string(ds->description) &&
empty_string(ds->notes) &&
ds->latitude.udeg == 0 &&