Chromium Code Reviews| 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; |
| } |