| Index: base/memory/scoped_ptr.h
|
| diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h
|
| index d93a8b401d70c275e232e022ed0c9d1dee7c5fa1..365c8f7ba48b1d6a3cb370fd9e0c53bc60ce44c6 100644
|
| --- a/base/memory/scoped_ptr.h
|
| +++ b/base/memory/scoped_ptr.h
|
| @@ -98,6 +98,7 @@
|
|
|
| #include "base/basictypes.h"
|
| #include "base/compiler_specific.h"
|
| +#include "base/debug/debugger.h"
|
| #include "base/move.h"
|
| #include "base/template_util.h"
|
|
|
| @@ -184,6 +185,17 @@ template <typename T> struct IsNotRefCounted {
|
| };
|
| };
|
|
|
| +template <typename T>
|
| +struct ShouldAbortOnSelfReset {
|
| + template <typename U>
|
| + static NoType Test(const typename U::AllowSelfReset*);
|
| +
|
| + template <typename U>
|
| + static YesType Test(...);
|
| +
|
| + static const bool value = sizeof(Test<T>(0)) == sizeof(YesType);
|
| +};
|
| +
|
| // Minimal implementation of the core logic of scoped_ptr, suitable for
|
| // reuse in both scoped_ptr and its specializations.
|
| template <class T, class D>
|
| @@ -222,9 +234,15 @@ class scoped_ptr_impl {
|
| }
|
|
|
| void reset(T* p) {
|
| - // This is a self-reset, which is no longer allowed: http://crbug.com/162971
|
| - if (p != nullptr && p == data_.ptr)
|
| - abort();
|
| + // This is a self-reset, which is no longer allowed for default deleters:
|
| + // https://crbug.com/162971
|
| + if (ShouldAbortOnSelfReset<D>::value && p != nullptr && p == data_.ptr) {
|
| + // TODO(dcheng): This is essentially what CHECK() does under the covers.
|
| + // However, that requires including base/logging.h. Since this file is
|
| + // included in some Blink code, and the Chromium logging defines conflict
|
| + // with Blink's, call base::debug::BreakDebugger() directly for now.
|
| + base::debug::BreakDebugger();
|
| + }
|
|
|
| // Note that running data_.ptr = p can lead to undefined behavior if
|
| // get_deleter()(get()) deletes this. In order to prevent this, reset()
|
|
|