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>
This commit is contained in:
Dirk Hohndel 2018-07-06 22:38:01 -07:00
parent 7297c5991b
commit 03bc40194d

View file

@ -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 &&