From 03bc40194d264226d1e666dab8a5e34a697c13fa Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 6 Jul 2018 22:38:01 -0700 Subject: 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 Signed-off-by: Dirk Hohndel --- core/divesite.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core') 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 && -- cgit v1.2.3-70-g09d2