From 1951371bbb1210b04a4133624734461286e4e44a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 27 Oct 2019 15:58:39 -0400 Subject: Cleanup: prevent NULL dereference This should never happen based on the logic in the callers, but just to be on the safe side. Should fix CID 350128 Signed-off-by: Dirk Hohndel --- core/divelist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/divelist.c b/core/divelist.c index c15ca8d3c..3c0570673 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -1471,7 +1471,7 @@ static int comp_dive_to_trip(struct dive *a, struct dive_trip *b) { /* This should never happen, nevertheless don't crash on trips * with no (or worse a negative number of) dives. */ - if (b->dives.nr <= 0) + if (!b || b->dives.nr <= 0) return -1; return comp_dives(a, b->dives.dives[0]); } -- cgit v1.2.3-70-g09d2