diff options
author | Robert C. Helling <helling@atdotde.de> | 2019-11-15 11:04:15 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-11-16 12:34:30 -0800 |
commit | dbb504429d89b472699bb8cfba8a751424e12139 (patch) | |
tree | bb51fcaccc280d924b5fbe260bc53e298f5b03cc /core/dive.c | |
parent | 143da031cee94a7d44668be52f90f2b3ec33c822 (diff) | |
download | subsurface-dbb504429d89b472699bb8cfba8a751424e12139.tar.gz |
Don't acces null dive computer
Fixes CID 350111
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/dive.c')
-rw-r--r-- | core/dive.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/dive.c b/core/dive.c index 20b39b6a3..23262540c 100644 --- a/core/dive.c +++ b/core/dive.c @@ -246,9 +246,11 @@ void add_extra_data(struct divecomputer *dc, const char *key, const char *value) enum divemode_t get_current_divemode(const struct divecomputer *dc, int time, const struct event **evp, enum divemode_t *divemode) { const struct event *ev = *evp; - if (*divemode == UNDEF_COMP_TYPE) { + if (*divemode == UNDEF_COMP_TYPE && dc) { *divemode = dc->divemode; - ev = dc ? get_next_event(dc->events, "modechange") : NULL; + ev = get_next_event(dc->events, "modechange"); + } else { + ev = NULL; } while (ev && ev->time.seconds < time) { *divemode = (enum divemode_t) ev->value; |