Commit e8e3cc70 authored by snuverink_j's avatar snuverink_j
Browse files

fix bug in assignment operator: check for equality before deletion and assignment

parent 950ed843
......@@ -135,9 +135,11 @@ inline Pointer<Object> &Pointer<Object>::operator=(const Pointer &rhs) {
template < class Object >
inline Pointer<Object> &Pointer<Object>::operator=(Object *obj) {
if(object && object->removeReference() <= 0) delete object;
object = obj;
if(object) object->addReference();
if(object != obj) {
if(object && object->removeReference() <= 0) delete object;
object = obj;
if(object) object->addReference();
}
return *this;
}
......
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