summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/memory/ref_counted.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h
index 1207ed4..e35264b 100644
--- a/base/memory/ref_counted.h
+++ b/base/memory/ref_counted.h
@@ -260,9 +260,10 @@ class scoped_refptr {
// AddRef first so that self assignment should work
if (p)
p->AddRef();
- if (ptr_ )
- ptr_ ->Release();
+ T* old_ptr = ptr_;
ptr_ = p;
+ if (old_ptr)
+ old_ptr ->Release();
return *this;
}