Fix a memory error in IdealGasPhase::cv_vib and cv_tr
The array 'c' is only long enough to hold the thermo parameters filled in by the StatMech class, so it's necessary to make sure the type is correct first and abort if it's not, rather than calling reportParams first and corrupting the stack.
This commit is contained in:
parent
123544e4f7
commit
d060cba434
1 changed files with 6 additions and 7 deletions
|
|
@ -103,18 +103,18 @@ doublereal IdealGasPhase::cv_tr(doublereal atomicity) const
|
|||
{
|
||||
// k is the species number
|
||||
int dum = 0;
|
||||
int type = 0;
|
||||
int type = m_spthermo->reportType();
|
||||
doublereal c[12];
|
||||
doublereal minTemp_;
|
||||
doublereal maxTemp_;
|
||||
doublereal refPressure_;
|
||||
|
||||
m_spthermo->reportParams(dum, type, c, minTemp_, maxTemp_, refPressure_);
|
||||
|
||||
if (type != 111) {
|
||||
throw CanteraError("Error in IdealGasPhase.cpp", "cv_tr only supported for StatMech!. \n\n");
|
||||
}
|
||||
|
||||
m_spthermo->reportParams(dum, type, c, minTemp_, maxTemp_, refPressure_);
|
||||
|
||||
// see reportParameters for specific details
|
||||
return c[3];
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ doublereal IdealGasPhase::cv_vib(const int k, const doublereal T) const
|
|||
|
||||
// k is the species number
|
||||
int dum = 0;
|
||||
int type = 0;
|
||||
int type = m_spthermo->reportType();
|
||||
doublereal c[12];
|
||||
doublereal minTemp_;
|
||||
doublereal maxTemp_;
|
||||
|
|
@ -142,14 +142,13 @@ doublereal IdealGasPhase::cv_vib(const int k, const doublereal T) const
|
|||
|
||||
c[0] = temperature();
|
||||
|
||||
m_spthermo->reportParams(dum, type, c, minTemp_, maxTemp_, refPressure_);
|
||||
|
||||
// basic sanity check
|
||||
if (type != 111) {
|
||||
throw CanteraError("Error in IdealGasPhase.cpp", "cv_vib only supported for StatMech!. \n\n");
|
||||
|
||||
}
|
||||
|
||||
m_spthermo->reportParams(dum, type, c, minTemp_, maxTemp_, refPressure_);
|
||||
|
||||
// see reportParameters for specific details
|
||||
return c[4];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue