mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add some assert guard around gas finding code
The code would have leaved gasidx undefined if it doesn't find a correct gas, so this asserts instead of using uninitialized variables as array index. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d84f397790
commit
28943d2def
1 changed files with 3 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
|||
*
|
||||
* (c) Dirk Hohndel 2013
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
@ -409,6 +410,7 @@ static struct gaschanges *analyze_gaslist(struct diveplan *diveplan, struct dive
|
|||
i++;
|
||||
}
|
||||
gaschanges[i].depth = dp->depth;
|
||||
gaschanges[i].gasidx = -1;
|
||||
do {
|
||||
if (dive->cylinder[j].gasmix.o2.permille == dp->o2 &&
|
||||
dive->cylinder[j].gasmix.he.permille == dp->he) {
|
||||
|
@ -417,6 +419,7 @@ static struct gaschanges *analyze_gaslist(struct diveplan *diveplan, struct dive
|
|||
}
|
||||
j++;
|
||||
} while (j < MAX_CYLINDERS);
|
||||
assert(gaschanges[i].gasidx != -1);
|
||||
}
|
||||
dp = dp->next;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue