diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-11-02 10:38:09 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-02 10:38:09 -0800 |
commit | 9eb55a0fc6b13dfd608009cac275bdbbbb71592c (patch) | |
tree | b289e0588816d61a2483b7376493746521046a63 /dive.c | |
parent | 6ce0afb99ccbc5fe940c4ca727afcf9cd33dffd5 (diff) | |
download | subsurface-9eb55a0fc6b13dfd608009cac275bdbbbb71592c.tar.gz |
Prevent segfault for dive with gas change but no samples
Not quite sure where such a dive would come from, but anyway, just don't
dereference the pointer unless it's non-NULL.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -789,7 +789,7 @@ static int same_rounded_pressure(pressure_t a, pressure_t b) int explicit_first_cylinder(struct dive *dive, struct divecomputer *dc) { struct event *ev = get_next_event(dc->events, "gaschange"); - if (ev && ev->time.seconds == dc->sample[0].time.seconds) + if (ev && dc && dc->sample && ev->time.seconds == dc->sample[0].time.seconds) return get_cylinder_index(dive, ev); else return 0; |