From a2028cd6ef4a52a18ec12d85c59b907f59715ce2 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 15 Oct 2018 16:01:24 -0400 Subject: 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 --- core/deco.c | 2 ++ 1 file changed, 2 insertions(+) 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; -- cgit v1.2.3-70-g09d2