Commit 6d4928d5 authored by Mark Olesen's avatar Mark Olesen

ENH: extend nullptr check for tmp ptr() method (#1775)

- Cannot call ptr_->clone() with a null pointer!
parent fde93b66
......@@ -260,15 +260,16 @@ inline T& Foam::tmp<T>::constCast() const
template<class T>
inline T* Foam::tmp<T>::ptr() const
{
if (!ptr_)
{
FatalErrorInFunction
<< typeName() << " deallocated"
<< abort(FatalError);
}
if (isTmp())
{
if (!ptr_)
{
FatalErrorInFunction
<< typeName() << " deallocated"
<< abort(FatalError);
}
else if (!ptr_->unique())
if (!ptr_->unique())
{
FatalErrorInFunction
<< "Attempt to acquire pointer to object referred to"
......
......@@ -224,15 +224,15 @@ inline T& Foam::tmpNrc<T>::constCast() const
template<class T>
inline T* Foam::tmpNrc<T>::ptr() const
{
if (isTmp())
if (!ptr_)
{
if (!ptr_)
{
FatalErrorInFunction
<< typeName() << " deallocated"
<< abort(FatalError);
}
FatalErrorInFunction
<< typeName() << " deallocated"
<< abort(FatalError);
}
if (isTmp())
{
T* p = ptr_;
ptr_ = nullptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment