From c92605158ac990f89207112314e5ce09e48ac284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com> Date: Sun, 9 Sep 2018 19:09:33 +0200 Subject: [PATCH] Fixed assignment of nullptr initialized SharedPointer. --- src/TNL/Pointers/SharedPointerCuda.h | 6 ++++-- src/TNL/Pointers/SharedPointerHost.h | 6 ++++-- src/TNL/Pointers/SharedPointerMic.h | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/TNL/Pointers/SharedPointerCuda.h b/src/TNL/Pointers/SharedPointerCuda.h index 7fdb4976f6..bdb938a9a1 100644 --- a/src/TNL/Pointers/SharedPointerCuda.h +++ b/src/TNL/Pointers/SharedPointerCuda.h @@ -191,7 +191,8 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer { this->free(); this->pd = (PointerData*) ptr.pd; - this->pd->counter += 1; + if( this->pd != nullptr ) + this->pd->counter += 1; return *this; } @@ -202,7 +203,8 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer { this->free(); this->pd = (PointerData*) ptr.pd; - this->pd->counter += 1; + if( this->pd != nullptr ) + this->pd->counter += 1; return *this; } diff --git a/src/TNL/Pointers/SharedPointerHost.h b/src/TNL/Pointers/SharedPointerHost.h index fd4dd0ba0f..a91174aa4a 100644 --- a/src/TNL/Pointers/SharedPointerHost.h +++ b/src/TNL/Pointers/SharedPointerHost.h @@ -163,7 +163,8 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer { this->free(); this->pd = (PointerData*) ptr.pd; - this->pd->counter += 1; + if( this->pd != nullptr ) + this->pd->counter += 1; return *this; } @@ -174,7 +175,8 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer { this->free(); this->pd = (PointerData*) ptr.pd; - this->pd->counter += 1; + if( this->pd != nullptr ) + this->pd->counter += 1; return *this; } diff --git a/src/TNL/Pointers/SharedPointerMic.h b/src/TNL/Pointers/SharedPointerMic.h index 65beab417c..7d578c8d6e 100644 --- a/src/TNL/Pointers/SharedPointerMic.h +++ b/src/TNL/Pointers/SharedPointerMic.h @@ -186,7 +186,8 @@ class SharedPointer< Object, Devices::MIC > : public SmartPointer this->free(); this->pd = (PointerData*) ptr.pd; this->mic_pointer = ptr.mic_pointer; - this->pd->counter += 1; + if( this->pd != nullptr ) + this->pd->counter += 1; #ifdef TNL_DEBUG_SHARED_POINTERS std::cerr << "Copy-assigned shared pointer: counter = " << this->pd->counter << ", type: " << demangle(typeid(ObjectType).name()) << std::endl; #endif @@ -201,7 +202,8 @@ class SharedPointer< Object, Devices::MIC > : public SmartPointer this->free(); this->pd = (PointerData*) ptr.pd; this->mic_pointer = ptr.mic_pointer; - this->pd->counter += 1; + if( this->pd != nullptr ) + this->pd->counter += 1; #ifdef TNL_DEBUG_SHARED_POINTERS std::cerr << "Copy-assigned shared pointer: counter = " << this->pd->counter << ", type: " << demangle(typeid(ObjectType).name()) << std::endl; #endif -- GitLab