diff --git a/dune/common/shared_ptr.hh b/dune/common/shared_ptr.hh index 77059386a9ab8d413b2266db1653e8244da9ae7e..2ba6f5bd78a412b351849503bdd648c2c8786523 100644 --- a/dune/common/shared_ptr.hh +++ b/dune/common/shared_ptr.hh @@ -214,14 +214,17 @@ namespace Dune template<class T> inline shared_ptr<T>::shared_ptr(const shared_ptr<T>& other) : rep_(other.rep_) { - ++(rep_->count_); + if (rep_) + ++(rep_->count_); } template<class T> inline shared_ptr<T>& shared_ptr<T>::operator=(const shared_ptr<T>& other) { - (other.rep_->count_)++; - if(rep_!=0 && --(rep_->count_)<=0) delete rep_; + if (other.rep_) { + (other.rep_->count_)++; + if(rep_!=0 && --(rep_->count_)<=0) delete rep_; + } rep_ = other.rep_; return *this; }