ENH: extend nullptr check for tmp ptr() method (#1775)
- Cannot call ptr_->clone() with a null pointer!
This commit is contained in:
parent
fde93b6603
commit
6d4928d585
@ -260,15 +260,16 @@ inline T& Foam::tmp<T>::constCast() const
|
|||||||
template<class T>
|
template<class T>
|
||||||
inline T* Foam::tmp<T>::ptr() const
|
inline T* Foam::tmp<T>::ptr() const
|
||||||
{
|
{
|
||||||
|
if (!ptr_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< typeName() << " deallocated"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
if (isTmp())
|
if (isTmp())
|
||||||
{
|
{
|
||||||
if (!ptr_)
|
if (!ptr_->unique())
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< typeName() << " deallocated"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
else if (!ptr_->unique())
|
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Attempt to acquire pointer to object referred to"
|
<< "Attempt to acquire pointer to object referred to"
|
||||||
|
@ -224,15 +224,15 @@ inline T& Foam::tmpNrc<T>::constCast() const
|
|||||||
template<class T>
|
template<class T>
|
||||||
inline T* Foam::tmpNrc<T>::ptr() const
|
inline T* Foam::tmpNrc<T>::ptr() const
|
||||||
{
|
{
|
||||||
|
if (!ptr_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< typeName() << " deallocated"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
if (isTmp())
|
if (isTmp())
|
||||||
{
|
{
|
||||||
if (!ptr_)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< typeName() << " deallocated"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
T* p = ptr_;
|
T* p = ptr_;
|
||||||
ptr_ = nullptr;
|
ptr_ = nullptr;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user