Fix potential segmentation fault and invalid read.

Cherry-pick of trunk r2676.
This commit is contained in:
Ray Speth 2014-01-23 03:06:29 +00:00
parent 0590c6c1a3
commit ee736fb306
3 changed files with 28 additions and 2 deletions

View file

@ -120,6 +120,16 @@ public:
const XML_Node* const phaseNode_ptr);
//@}
//! Initialize the internal shallow pointers in this object
/*!
* There are a bunch of internal shallow pointers that point to the owning
* VPStandardStateTP and SpeciesThermo objects. This function reinitializes
* them. This function is called like an onion.
*
* @param vp_ptr Pointer to the VPStandardStateTP standard state
* @param sp_ptr Pointer to the SpeciesThermo standard state
*/
virtual void initAllPtrs(VPStandardStateTP* vp_ptr, SpeciesThermo* sp_ptr);
private:
//! Shallow pointer to the water object
PDSS_Water* m_waterSS;

View file

@ -81,7 +81,8 @@ MetalSHEelectrons::MetalSHEelectrons(XML_Node& xmlphase, const std::string& id_)
}
MetalSHEelectrons::MetalSHEelectrons(const MetalSHEelectrons& right) :
SingleSpeciesTP()
SingleSpeciesTP(),
xdef_(0)
{
operator=(right);
}
@ -99,7 +100,10 @@ MetalSHEelectrons::operator=(const MetalSHEelectrons& right)
}
delete xdef_;
xdef_ = new XML_Node(*right.xdef_);
if(right.xdef_)
{
xdef_ = new XML_Node(*right.xdef_);
}
return *this;
}

View file

@ -299,6 +299,18 @@ VPSSMgr_Water_HKFT::createInstallPDSS(size_t k, const XML_Node& speciesNode,
return kPDSS;
}
void
VPSSMgr_Water_HKFT::initAllPtrs(VPStandardStateTP* vp_ptr,
SpeciesThermo* sp_ptr)
{
VPSSMgr::initAllPtrs(vp_ptr, sp_ptr);
m_waterSS = dynamic_cast<PDSS_Water*>(m_vptp_ptr->providePDSS(0));
if (!m_waterSS) {
throw CanteraError("VPSSMgr_Water_ConstVol::initAllPtrs",
"bad dynamic cast");
}
}
PDSS_enumType VPSSMgr_Water_HKFT::reportPDSSType(int k) const
{
return cPDSS_UNDEF;