From 33c54e5d767ca33b053c6c191561616d886ec98a Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Tue, 9 May 2017 22:30:02 +0200 Subject: [PATCH] Fix crash in PT_vs_hpt() due to invalid data in ISA_def In commit 15525aab58a77582f537ad4c26d4e47818539559, a layer with lapse=0.0 was added to ISA_def (atmosphere model). However, the last layer *must* have lapse == -1.0, otherwise the code in PT_vs_hpt() doesn't know when it's on the last element of ISA_def, and does an illegal memory access with (pp+1)->height. This is why -1.0 is the default value for lapse ('l') in the ISA_layer constructor. Fix: add the -1.0 terminator to the last element of ISA_def. --- src/Environment/atmosphere.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Environment/atmosphere.cxx b/src/Environment/atmosphere.cxx index dc823292f..a6720c241 100644 --- a/src/Environment/atmosphere.cxx +++ b/src/Environment/atmosphere.cxx @@ -20,7 +20,8 @@ ISA_layer(4, 47000, 154199, 110.906, 0.0327506, 270.65, -2.50, 0, ISA_layer(5, 51000, 167322, 66.9389, 0.0197670, 270.65, -2.50, 0.0028, 0.0008534), ISA_layer(6, 71000, 232939, 3.95642, 0.00116833, 214.65, -58.50, 0.0020, 0.0006096), ISA_layer(7, 80000, 262467, 0.88628, 0.000261718, 196.65, -76.50, 0.0, 0.0), -ISA_layer(8, 1.0e9, 3.28e9, 0.00001, 3.0e-9, 2.73, -270.4, 0.0, 0.0), +// The last layer MUST have -1.0 for its 'lapse' field +ISA_layer(8, 1.0e9, 3.28e9, 0.00001, 3.0e-9, 2.73, -270.4, -1.0) }; // Pressure within a layer, as a function of height.