Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2234)

Unified Diff: base/memory/ref_counted.h

Issue 9021020: Fix scoped_refptr assignment operator in the case of having it as a member. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactored as joth suggests Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/memory/ref_counted_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/ref_counted.h
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h
index 439fda44d1ad4505b6c3666af601450ce45d1a43..ad9722e1b991e5265162fac3bb8de5e248d86341 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;
}
« no previous file with comments | « no previous file | base/memory/ref_counted_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698