diff options
author | Robert C. Helling <helling@atdotde.de> | 2020-01-02 23:46:06 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-01-05 04:15:42 +0900 |
commit | 95a0a0f5a6038d5a73775e2060e29d09d0953d7e (patch) | |
tree | c0301d6895ec9ea506a5555b9ecbcd5ea07cac4c /core/dive.c | |
parent | c77bad6c3e29927db83634b2b8409144ac833123 (diff) | |
download | subsurface-95a0a0f5a6038d5a73775e2060e29d09d0953d7e.tar.gz |
Fix get_divemode logic
Commit dbb504 tried to prevent an uninitialized dc pointer
from being dereferenced. But I screwed up the logic always
setting the event pointer to NULL. This fixes this error.
Reported-by: willemferguson@zoology.up.ac.za
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/dive.c')
-rw-r--r-- | core/dive.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/core/dive.c b/core/dive.c index 23262540c..0cf050ba9 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 && dc) { - *divemode = dc->divemode; - ev = get_next_event(dc->events, "modechange"); + if (dc) { + if (*divemode == UNDEF_COMP_TYPE) { + *divemode = dc->divemode; + ev = get_next_event(dc->events, "modechange"); + } } else { ev = NULL; } |