diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-10-27 15:58:39 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-28 05:44:33 -0700 |
commit | 1951371bbb1210b04a4133624734461286e4e44a (patch) | |
tree | 254bd8987b0a602d396737b2b468e673b347e158 | |
parent | b0a00cd15de4b255139fefde3da36c28bd0b31bc (diff) | |
download | subsurface-1951371bbb1210b04a4133624734461286e4e44a.tar.gz |
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>
-rw-r--r-- | core/divelist.c | 2 |
1 files changed, 1 insertions, 1 deletions
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]); } |