mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
a3238020ee
commit
d81df0dd19
1 changed files with 4 additions and 0 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue