summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2018-10-15 16:01:24 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-15 20:57:25 -0400
commita2028cd6ef4a52a18ec12d85c59b907f59715ce2 (patch)
tree5eda0052a1e71f0d3f1a79ab1403098e0fe323f8
parent0e00d40ead4c8a87a0dbc685db4efda2b9d2205c (diff)
downloadsubsurface-a2028cd6ef4a52a18ec12d85c59b907f59715ce2.tar.gz
deco: _really_ make sure the deco state is fully initialized
I incorrectly thought that 'ci_pointing_to_guiding_tissue' was the only missing initialization, because that is the only one valgrind pointed at. ... that is, until I started looking at a few more dives, which showed that there were other parts tht weren't initialized either, like double tolerated_by_tissue[16]; double tissue_inertgas_saturation[16]; double crushing_onset_tension[16]; // total inert gas tension in the t* moment so just make sure to clear the whole data structure, to avoid any random behavior due to uninitialized deco state. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--core/deco.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/deco.c b/core/deco.c
index 108d4189e..78ab23f0a 100644
--- a/core/deco.c
+++ b/core/deco.c
@@ -540,6 +540,8 @@ void clear_vpmb_state(struct deco_state *ds) {
void clear_deco(struct deco_state *ds, double surface_pressure)
{
int ci;
+
+ memset(ds, 0, sizeof(*ds));
clear_vpmb_state(ds);
for (ci = 0; ci < 16; ci++) {
ds->tissue_n2_sat[ci] = (surface_pressure - ((in_planner() && (decoMode() == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * N2_IN_AIR / 1000;