From ce1be9c2eb7df515690d4861a5ed3f813b82c076 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 21 Jun 2015 21:17:42 -0700 Subject: 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 --- gaspressures.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gaspressures.c') 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) { -- cgit v1.2.3-70-g09d2