mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Don't crash if get_divenr is called with NULL argument
We shouldn't be doing that, but still, let's not crash. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
da911993f1
commit
947d7b77df
1 changed files with 6 additions and 4 deletions
10
divelist.c
10
divelist.c
|
@ -338,10 +338,12 @@ int get_divenr(struct dive *dive)
|
|||
{
|
||||
int i;
|
||||
struct dive *d;
|
||||
for_each_dive(i, d) {
|
||||
if (d->id == dive->id) // don't compare pointers, we could be passing in a copy of the dive
|
||||
return i;
|
||||
}
|
||||
// tempting as it may be, don't die when called with dive=NULL
|
||||
if (dive)
|
||||
for_each_dive(i, d) {
|
||||
if (d->id == dive->id) // don't compare pointers, we could be passing in a copy of the dive
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue