summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-03-06 16:16:10 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-03-06 16:16:10 -0800
commit211ff0e63b604e06a7ae98bf0693715bbf426e64 (patch)
treef29ccc3dcb85f939507c452857f4bdf4159eb614 /profile.c
parent8ab1fa398364577f1f3fe4a30f1a60c13801d347 (diff)
downloadsubsurface-211ff0e63b604e06a7ae98bf0693715bbf426e64.tar.gz
Fix theoretical uninitialized read
We should never read cur_pr[cyl] if cyl isn't used during a dive - but for cylinders that are used cur_pr[cyl] is initialized. But just to catch errors elsewhere, let's not leave cur_pr[cyl] uninitialized. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/profile.c b/profile.c
index b7f80f9f0..e5b15f59f 100644
--- a/profile.c
+++ b/profile.c
@@ -585,8 +585,11 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
dump_pr_track(track_pr);
#endif
for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
- if (!track_pr[cyl])
+ if (!track_pr[cyl]) {
+ /* no segment where this cylinder is used */
+ cur_pr[cyl] = -1;
continue;
+ }
fill_missing_segment_pressures(track_pr[cyl]);
cur_pr[cyl] = track_pr[cyl]->start;
}