summaryrefslogtreecommitdiffstats
path: root/base/memory
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 02:16:55 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 02:16:55 +0000
commit2766513bf44b1f62faf09956899114d3d6d64267 (patch)
tree4a2da691cacbc28d2b20e3657bea94d80b7f490d /base/memory
parent8db04987509e981472144182ec0e96c2a3abc218 (diff)
downloadchromium_src-2766513bf44b1f62faf09956899114d3d6d64267.zip
chromium_src-2766513bf44b1f62faf09956899114d3d6d64267.tar.gz
chromium_src-2766513bf44b1f62faf09956899114d3d6d64267.tar.bz2
Add assert() for scoped_refptr<T>::operator->()
This is to make NULL dereference crashes more obvious. Also matches scoped_ptr (which uses assert) and weak_ptr (which uses DCHECK). DCHECK wasn't used because it pulls in logging.h, and that somehow conflicts with a webkit #define of LOG. BUG= TEST= Review URL: http://codereview.chromium.org/9232069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119820 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/memory')
-rw-r--r--base/memory/ref_counted.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h
index b7cb5e0..cf8ff16 100644
--- a/base/memory/ref_counted.h
+++ b/base/memory/ref_counted.h
@@ -6,6 +6,8 @@
#define BASE_MEMORY_REF_COUNTED_H_
#pragma once
+#include <cassert>
+
#include "base/atomic_ref_count.h"
#include "base/base_export.h"
#include "base/threading/thread_collision_warner.h"
@@ -243,7 +245,10 @@ class scoped_refptr {
T* get() const { return ptr_; }
operator T*() const { return ptr_; }
- T* operator->() const { return ptr_; }
+ T* operator->() const {
+ assert(ptr_ != NULL);
+ return ptr_;
+ }
// Release a pointer.
// The return value is the current pointer held by this object.