Desktop: support no-cylinders in dive information tab

The tab was crashing if there were no cylinders because
1) per_cylinder_mean_depth() would access non-existing cylinders.
2) TabDiveInformation::updateProfile() would access a non-existing
   mean.

Fix both of these crash conditions by checking whether the dive
actually has cylinders.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-08-04 19:49:43 +02:00 committed by Dirk Hohndel
parent fd23c3d908
commit 6a1e2cd8c2
2 changed files with 4 additions and 1 deletions

View file

@ -753,6 +753,9 @@ void per_cylinder_mean_depth(const struct dive *dive, struct divecomputer *dc, i
bool *used_cylinders;
int num_used_cylinders;
if (dive->cylinders.nr <= 0)
return;
for (i = 0; i < dive->cylinders.nr; i++)
mean[i] = duration[i] = 0;
if (!dc)