[Scummvm-cvs-logs] CVS: residual resource.h,1.1,1.2
Daniel Schepler
dschepler at users.sourceforge.net
Sat Aug 16 20:19:17 CEST 2003
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1:/tmp/cvs-serv8661
Modified Files:
resource.h
Log Message:
Fix bug in ResPtr template where assigning the same pointer it already
contained could cause it to free the object.
Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/residual/resource.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- resource.h 15 Aug 2003 19:41:26 -0000 1.1
+++ resource.h 17 Aug 2003 02:48:07 -0000 1.2
@@ -61,12 +61,14 @@
T& operator *() { return *ptr_; }
T* operator ->() { return ptr_; }
ResPtr& operator =(T* ptr) {
+ if (ptr_ == ptr) return *this;
if (ptr_ != NULL) ptr_->deref();
ptr_ = ptr;
if (ptr_ != NULL) ptr_->ref();
return *this;
}
ResPtr& operator =(const ResPtr& p) {
+ if (this == &p || ptr_ == p.ptr_) return *this;
if (ptr_ != NULL) ptr_->deref();
ptr_ = p.ptr_;
if (ptr_ != NULL) ptr_->ref();
More information about the Scummvm-git-logs
mailing list