[Reactor] Fix null pointer dereference in FlowDevice::install

Taking the address of a dereferenced null pointer is still undefined
behavior. This was causing the test TestReactor.test_valve_errors to fail on
some versions of OS X.
This commit is contained in:
Ray Speth 2016-01-28 15:26:36 -05:00
parent d35f6ab6f2
commit d7b1216f56
2 changed files with 8 additions and 4 deletions

View file

@ -133,10 +133,18 @@ public:
//! return a reference to the contents.
thermo_t& contents() {
if (!m_thermo) {
throw CanteraError("ReactorBase::contents",
"Reactor contents not defined.");
}
return *m_thermo;
}
const thermo_t& contents() const {
if (!m_thermo) {
throw CanteraError("ReactorBase::contents",
"Reactor contents not defined.");
}
return *m_thermo;
}

View file

@ -19,10 +19,6 @@ bool FlowDevice::install(ReactorBase& in, ReactorBase& out)
// construct adapters between inlet and outlet species
ThermoPhase* mixin = &m_in->contents();
ThermoPhase* mixout = &m_out->contents();
if (mixin == 0 || mixout == 0) {
throw CanteraError("FlowDevice::install", "Can't install flow device "
"until reactor contents have been assigned.");
}
m_nspin = mixin->nSpecies();
m_nspout = mixout->nSpecies();