[PATCH] profile.c: fix a bug in calculate_gas_information_new()
Lubomir I. Ivanov
neolit123 at gmail.com
Wed Nov 12 12:24:36 PST 2014
From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
In a test case loading dives/test35.xml results in a infinite(-like)
loop (Note: possibly requires the partial pressure plots enabled).
calculate_gas_information_new() has an 'if' branch to
update the cylinderindex to a dive's diluent_cylinder_index,
but it does not consider that said index can be set previously
to -1.
This results in a random neighbour memory assigned as
&dive->cylinder[-1].gasmix and passed to fill_pressures(..).
Following the calculations in the function the He gas,
can receive a bad value (e.g. for the test case in the
E+6 ranges).
Said value is then used in DivePlotDataModel()::pheMax()
(defined by MAX_PPGAS_FUNC()) resulting in one of the loops
(the 3rd one) in DiveCartesianAxis::updateTicks() to
loop indefinitely.
Fixes #759
Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
resent to the mailing list.
---
profile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profile.c b/profile.c
index d3c5ef8..82d4b65 100644
--- a/profile.c
+++ b/profile.c
@@ -900,7 +900,7 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p
amb_pressure = depth_to_mbar(entry->depth, dive) / 1000.0;
// For CCR dives use the diluent gas composition for calculating partial gas pressures:
- if ((dive->dc.dctype == CCR) && (cylinderindex == dive->oxygen_cylinder_index))
+ if (dive->dc.dctype == CCR && cylinderindex == dive->oxygen_cylinder_index && dive->diluent_cylinder_index != -1)
cylinderindex = dive->diluent_cylinder_index;
fill_pressures(&entry->pressures, amb_pressure, &dive->cylinder[cylinderindex].gasmix, entry->pressures.o2, dive->dc.dctype, entry->sac);
--
1.7.11.msysgit.0
More information about the subsurface
mailing list