summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorFengwei Yin <fengwei.yin@intel.com>2012-05-24 16:47:48 +0800
committerShuo Gao <shuo.gao@intel.com>2012-08-15 10:40:58 +0800
commitc2cbc7df84951541b29200c3a6ade3163fb815ae (patch)
tree5caa522ea6cc15a144382cf80455b8fa8e1f105b /base
parent1c684ed1b5ac92ae473db5718627405367eb1766 (diff)
downloadexternal_chromium-c2cbc7df84951541b29200c3a6ade3163fb815ae.zip
external_chromium-c2cbc7df84951541b29200c3a6ade3163fb815ae.tar.gz
external_chromium-c2cbc7df84951541b29200c3a6ade3163fb815ae.tar.bz2
back port upstream patch
This patch is from Chromium project. It's used to handle potential issue in scoped_refptr. This is upstream patch porting and the original link is: http://codereview.chromium.org/9021020/ unittest change was not included. Change-Id: I14ce3df0653ff29713f38eceaf07e9b409cfaedc Author: Fengwei Yin <fengwei.yin@intel.com> Singed-off-by: Shuo Gao <shuo.gao@intel.com> Signed-off-by: Bruce Beare <bruce.j.beare@intel.com> Signed-off-by: Jack Ren <jack.ren@intel.com> Author-tracking-BZ: 37500
Diffstat (limited to 'base')
-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;
}