Skip to content

Commit

Permalink
[Equil] Check index bounds for known problems in VCS_SOLVE
Browse files Browse the repository at this point in the history
See #187
  • Loading branch information
speth committed May 3, 2016
1 parent aa5f26b commit 2561ab8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/equil/vcs_phaseStability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ size_t VCS_SOLVE::vcs_popPhaseID(std::vector<size_t> & phasePopPhaseIDs)
// Single Phase Stability Resolution
size_t kspec = Vphase->spGlobalIndexVCS(0);
size_t irxn = kspec - m_numComponents;
if (irxn > m_deltaGRxn_old.size()) {
throw CanteraError("VCS_SOLVE::vcs_popPhaseID",
"Index out of bounds due to logic error.");
}
doublereal deltaGRxn = m_deltaGRxn_old[irxn];
Fephase = exp(-deltaGRxn) - 1.0;
if (Fephase > 0.0) {
Expand Down Expand Up @@ -370,6 +374,10 @@ int VCS_SOLVE::vcs_popPhaseRxnStepSizes(const size_t iphasePop)
double delmol = deltaMolNumPhase * X_est[k];
if (kspec >= m_numComponents) {
irxn = kspec - m_numComponents;
if (irxn > m_stoichCoeffRxnMatrix.nColumns()) {
throw CanteraError("VCS_SOLVE::vcs_popPhaseRxnStepSizes",
"Index out of bounds due to logic error.");
}
for (size_t j = 0; j < m_numComponents; ++j) {
double stoicC = m_stoichCoeffRxnMatrix(j,irxn);
if (stoicC != 0.0 && m_elType[j] == VCS_ELEM_TYPE_ABSPOS) {
Expand Down

0 comments on commit 2561ab8

Please sign in to comment.