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
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…
x
Reference in New Issue
Block a user