From c763970de6e749123af76170c16bbc3929058437 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 11 Apr 2018 21:18:38 +0000 Subject: Fix issues with PDFium third_party/base/span.h Remove stray const in operator[] that was introduced when downgrading from C++14 to C++11 syntax. Add missing Get() in first() that was introduced when converting to UnownedPtr. Prevent ASAN from flagging spans where the UnownedPtr points to byte N+1 of a N byte object, and the span is empty. This is legal in C for ordinary pointers so long as the pointer isn't de-referenced, but is not allowed per the rules for UnownedPtr. Change-Id: Ic143c5ef4e37c1cf86f0a3e5408be6e2076a85e2 Reviewed-on: https://pdfium-review.googlesource.com/30212 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- core/fxcrt/unowned_ptr.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'core/fxcrt/unowned_ptr.h') diff --git a/core/fxcrt/unowned_ptr.h b/core/fxcrt/unowned_ptr.h index 0e3bf9e09b..0a44f9db52 100644 --- a/core/fxcrt/unowned_ptr.h +++ b/core/fxcrt/unowned_ptr.h @@ -35,6 +35,13 @@ // other heap object. Use pdfium::span<> for the cases where indexing // into an unowned array is desired, which performs the same checks. +namespace pdfium { + +template +class span; + +} // namespace pdfium + namespace fxcrt { template @@ -95,6 +102,8 @@ class UnownedPtr { T* operator->() const { return m_pObj; } private: + friend class pdfium::span; + inline void ProbeForLowSeverityLifetimeIssue() { #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) if (m_pObj) @@ -102,6 +111,12 @@ class UnownedPtr { #endif } + inline void ReleaseBadPointer() { +#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) + m_pObj = nullptr; +#endif + } + T* m_pObj = nullptr; }; -- cgit v1.2.3