mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Avoid working with invalid dive indices
When calling merge_two_dives both dives should be in the dive list so i and j should never be -1. But just as extra precaution, bail if that's the case (so that the helper functions below aren't called with negative indices). Coverity CID 1189514 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6b9aea1b96
commit
d9bbb97bd0
1 changed files with 3 additions and 0 deletions
|
@ -833,6 +833,9 @@ struct dive *merge_two_dives(struct dive *a, struct dive *b)
|
||||||
id = a->id;
|
id = a->id;
|
||||||
i = get_divenr(a);
|
i = get_divenr(a);
|
||||||
j = get_divenr(b);
|
j = get_divenr(b);
|
||||||
|
if (i < 0 || j < 0)
|
||||||
|
// something is wrong with those dives. Bail
|
||||||
|
return NULL;
|
||||||
res = merge_dives(a, b, b->when - a->when, false);
|
res = merge_dives(a, b, b->when - a->when, false);
|
||||||
if (!res)
|
if (!res)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue