diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-07-03 21:18:40 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-03 21:18:40 -0700 |
commit | 947d7b77df48cfa251a6f3a56b6b56d3bc33747f (patch) | |
tree | 8d8cb9ec9b10c39b467dbbd7d13a6123c97e5025 /divelist.c | |
parent | da911993f12b2ea3f519294c1c4d160c97cda54f (diff) | |
download | subsurface-947d7b77df48cfa251a6f3a56b6b56d3bc33747f.tar.gz |
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>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/divelist.c b/divelist.c index d1634a634..632b7703c 100644 --- a/divelist.c +++ b/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; } |