From 98d113182be15c0c09ceed91148a93de6b51ef99 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 24 Mar 2014 21:36:48 +0000 Subject: [PATCH] [Thermo] Fix possible invalid read in installShomateThermoFromXML installShomateThermoFromXML now checks that 7 coefficients are supplied in the floatArray and throws if that is not the case. Partial cherry-pick of r2778. --- src/thermo/SpeciesThermoFactory.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/thermo/SpeciesThermoFactory.cpp b/src/thermo/SpeciesThermoFactory.cpp index 37163bc56..4da1522c1 100644 --- a/src/thermo/SpeciesThermoFactory.cpp +++ b/src/thermo/SpeciesThermoFactory.cpp @@ -462,6 +462,11 @@ static void installShomateThermoFromXML(const std::string& speciesName, SpeciesT if (dualRange) { getFloatArray(f1ptr->child("floatArray"), c1, false); } else { + if(c0.size() != 7) + { + throw CanteraError("installShomateThermoFromXML", + "Shomate thermo requires 7 coefficients in float array."); + } c1.resize(7,0.0); copy(c0.begin(), c0.begin()+7, c1.begin()); } @@ -475,6 +480,11 @@ static void installShomateThermoFromXML(const std::string& speciesName, SpeciesT throw CanteraError("installShomateThermoFromXML", "non-continuous temperature ranges."); } + if(c0.size() != 7 || c1.size() != 7) + { + throw CanteraError("installShomateThermoFromXML", + "Shomate thermo requires 7 coefficients in float array."); + } vector_fp c(15); c[0] = tmid; copy(c0.begin(), c0.begin()+7, c.begin() + 1);