diff --git a/layout/base/nsPresArena.cpp b/layout/base/nsPresArena.cpp index 3187629a85c..be0f0f57fbd 100644 --- a/layout/base/nsPresArena.cpp +++ b/layout/base/nsPresArena.cpp @@ -108,11 +108,7 @@ nsPresArena::Free(uint32_t aCode, void* aPtr) NS_ABORT_IF_FALSE(list, "no free list for pres arena object"); NS_ABORT_IF_FALSE(list->mEntrySize > 0, "PresArena cannot free zero bytes"); - char* p = reinterpret_cast(aPtr); - char* limit = p + list->mEntrySize; - for (; p < limit; p += sizeof(uintptr_t)) { - *reinterpret_cast(p) = mozPoisonValue(); - } + mozWritePoison(aPtr, list->mEntrySize); MOZ_MAKE_MEM_NOACCESS(aPtr, list->mEntrySize); list->mEntries.AppendElement(aPtr); diff --git a/layout/style/nsRuleData.cpp b/layout/style/nsRuleData.cpp index b5d2a34ab80..ac6b4fb26b9 100644 --- a/layout/style/nsRuleData.cpp +++ b/layout/style/nsRuleData.cpp @@ -4,8 +4,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsRuleData.h" -#include "nsPresArena.h" +#include "mozilla/Poison.h" #include "mozilla/StandardInteger.h" inline size_t @@ -20,7 +20,7 @@ nsRuleData::GetPoisonOffset() "expect uintptr_t to be unsigned"); MOZ_STATIC_ASSERT(size_t(-1) > size_t(0), "expect size_t to be unsigned"); - uintptr_t framePoisonValue = nsPresArena::GetPoisonValue(); + uintptr_t framePoisonValue = mozPoisonValue(); return size_t(framePoisonValue - uintptr_t(mValueStorage)) / sizeof(nsCSSValue); } diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 8a3af2654b1..9dc7bfbe0ee 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -8,6 +8,7 @@ #include "mozilla/Attributes.h" #include "mozilla/DebugOnly.h" #include "mozilla/Likely.h" +#include "mozilla/Poison.h" #include "nsIWidget.h" #include "nsViewManager.h" #include "nsIFrame.h" @@ -132,14 +133,7 @@ nsView* nsView::GetViewFor(nsIWidget* aWidget) void nsView::Destroy() { this->~nsView(); - - const uintptr_t POISON = nsPresArena::GetPoisonValue(); - char* p = reinterpret_cast(this); - char* limit = p + sizeof(*this); - for (; p < limit; p += sizeof(uintptr_t)) { - *reinterpret_cast(p) = POISON; - } - + mozWritePoison(this, sizeof(*this)); nsView::operator delete(this); }