summaryrefslogtreecommitdiffstats
path: root/core/trip.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/trip.c')
-rw-r--r--core/trip.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/trip.c b/core/trip.c
index 570bd1fee..8f153d587 100644
--- a/core/trip.c
+++ b/core/trip.c
@@ -74,10 +74,12 @@ bool is_trip_before_after(const struct dive *dive, bool before)
{
int idx = get_idx_by_uniq_id(dive->id);
if (before) {
- if (idx > 0 && get_dive(idx - 1)->divetrip)
+ const struct dive *d = get_dive(idx - 1);
+ if (d && d->divetrip)
return true;
} else {
- if (idx < dive_table.nr - 1 && get_dive(idx + 1)->divetrip)
+ const struct dive *d = get_dive(idx + 1);
+ if (d && d->divetrip)
return true;
}
return false;