base::AsWeakPtr crashes on null pointer |
||
Issue descriptionhttps://cs.chromium.org/chromium/src/base/memory/weak_ptr.h?l=373&rcl=6f07ce6c4c237245bb0392c632c7847b29000ee6 base::AsWeakPtr(p) crashes if passed a null pointer. This is surprising and undocumented. I would have expected it to return a null WeakPtr.
,
Nov 20 2017
The function template template <typename Derived> WeakPtr<Derived> AsWeakPtr(Derived* t) looks and feels like a pointer cast operator, similar to static_cast, dynamic_cast or std::static_pointer_cast. All these pointer cast operators are null-friendly. Our WeakPtr's conversion constructor is also null-friendly: it converts a null WeakPtr<U> to a null WeakPtr<T>. However, AsWeakPtr(Derived*) crashes on a null pointer. This is surprising and undocumented. This feels more like an oversight than a deliberate feature. And this can easily be fixed.
,
Nov 29 2017
|
||
►
Sign in to add a comment |
||
Comment 1 by fdegros@chromium.org
, Nov 16 2017