mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: extend nullptr check for tmp ptr() method (#1775)
- Cannot call ptr_->clone() with a null pointer!
This commit is contained in:
@ -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 (!ptr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< typeName() << " deallocated"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (isTmp())
|
||||
{
|
||||
if (!ptr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< typeName() << " deallocated"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
T* p = ptr_;
|
||||
ptr_ = nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user