diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-20 21:12:54 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-04-20 12:59:06 -0700 |
commit | d81df0dd198221ddec4571874507264ace8e21f3 (patch) | |
tree | c58754042f54560ed1503056156ed5eedded7802 /core | |
parent | a3238020eebedaf110bd0b63a9f16aa2b605efe0 (diff) | |
download | subsurface-d81df0dd198221ddec4571874507264ace8e21f3.tar.gz |
profile: avoid invalid accesses in setup_gas_sensor_pressure
Since we removed MAX_CYLINDERS, we have the possibility of dives
with no cylinders. In such a case, setup_gas_sensor_pressure()
would do invalid read- and write-accesses. Therefore, return
early in such a case.
Reported-by: Chirana Gheorghita Eugeniu Theodor <office@adaptcom.ro>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r-- | core/profile.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/core/profile.c b/core/profile.c index 109ec4508..efcfe45a4 100644 --- a/core/profile.c +++ b/core/profile.c @@ -844,6 +844,10 @@ static void setup_gas_sensor_pressure(const struct dive *dive, const struct dive { int prev, i; const struct event *ev; + + if (pi->nr_cylinders == 0) + return; + int *seen = malloc(pi->nr_cylinders * sizeof(*seen)); int *first = malloc(pi->nr_cylinders * sizeof(*first)); int *last = malloc(pi->nr_cylinders * sizeof(*last)); |