summaryrefslogtreecommitdiffstats
path: root/gaspressures.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-21 21:17:42 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-21 21:17:42 -0700
commitce1be9c2eb7df515690d4861a5ed3f813b82c076 (patch)
tree333ec55e71bb04990eba0987a7adfe497d58ac32 /gaspressures.c
parentf5726c3d184dce88822fd84dbe994d6fa92c089b (diff)
downloadsubsurface-ce1be9c2eb7df515690d4861a5ed3f813b82c076.tar.gz
Prevent theoretical out of bounds access
When I stare at the code enough I can convince myself that cylinderindex will always be assigned a sane value, but on the flip side, making sure nothing stupid happens is cheap insurance. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gaspressures.c')
-rw-r--r--gaspressures.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/gaspressures.c b/gaspressures.c
index 4edcf7e35..5f46d6080 100644
--- a/gaspressures.c
+++ b/gaspressures.c
@@ -417,7 +417,8 @@ void populate_pressure_information(struct dive *dive, struct divecomputer *dc, s
/* transmitter stopped transmitting cylinder pressure data */
current = pr_track_alloc(pressure, entry->sec);
- track_pr[cylinderindex] = list_add(track_pr[cylinderindex], current);
+ if (cylinderindex >= 0)
+ track_pr[cylinderindex] = list_add(track_pr[cylinderindex], current);
}
if (missing_pr) {