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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2019-10-27 15:58:39 -04:00
parent b0a00cd15d
commit 1951371bbb

View file

@ -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]);
}