[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.
This commit is contained in:
Ray Speth 2014-03-24 21:36:48 +00:00
parent 7f5ea6edb3
commit 98d113182b

View file

@ -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);