From 889176b3a3b5b71cc05c51dad3e7d2ddac610b7e Mon Sep 17 00:00:00 2001 From: Ethan Nicholas Date: Mon, 23 Jan 2017 19:59:26 +0000 Subject: Revert "Fix comparison that overflows for addresses near uint max." This reverts commit db8b8376b09cec9656b0ab864413b7911d81a84c. Reason for revert: Assertion failure, see https://luci-milo.appspot.com/swarming/task/33e5ae4d2bb25210/steps/dm/0/stdout Original change's description: > Fix comparison that overflows for addresses near uint max. > > BUG=chromium:683578 > > Change-Id: I3f9b79eeeba3c68cccb72bd6423811c8ff8f2067 > Reviewed-on: https://skia-review.googlesource.com/7410 > Commit-Queue: Herb Derby > Commit-Queue: Mike Klein > Reviewed-by: Mike Klein > TBR=mtklein@chromium.org,mtklein@google.com,herb@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=chromium:683578 Change-Id: I198ea4c7209d060d0d15dfa3f6e555fa06e1a632 Reviewed-on: https://skia-review.googlesource.com/7415 Commit-Queue: Ethan Nicholas Reviewed-by: Ethan Nicholas --- src/core/SkArenaAlloc.cpp | 4 ++-- src/core/SkArenaAlloc.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/SkArenaAlloc.cpp b/src/core/SkArenaAlloc.cpp index 39d1ed5fc8..5ac08dcdc3 100644 --- a/src/core/SkArenaAlloc.cpp +++ b/src/core/SkArenaAlloc.cpp @@ -123,7 +123,7 @@ void SkArenaAlloc::ensureSpace(size_t size, size_t alignment) { char* SkArenaAlloc::allocObject(size_t size, size_t alignment) { size_t mask = alignment - 1; char* objStart = (char*)((uintptr_t)(fCursor + mask) & ~mask); - if (size > (size_t)(fEnd - objStart)) { + if (objStart + size > fEnd) { this->ensureSpace(size, alignment); objStart = (char*)((uintptr_t)(fCursor + mask) & ~mask); } @@ -142,7 +142,7 @@ restart: char* objStart = (char*)((uintptr_t)(fCursor + skipOverhead + mask) & ~mask); size_t totalSize = sizeIncludingFooter + skipOverhead; - if (totalSize > (size_t)(fEnd - objStart)) { + if (objStart + totalSize > fEnd) { this->ensureSpace(totalSize, alignment); goto restart; } diff --git a/src/core/SkArenaAlloc.h b/src/core/SkArenaAlloc.h index 589f782b1e..532b45aa25 100644 --- a/src/core/SkArenaAlloc.h +++ b/src/core/SkArenaAlloc.h @@ -68,7 +68,6 @@ public: template T* make(Args&&... args) { - SkASSERT(SkTFitsIn(sizeof(T))); char* objStart; if (skstd::is_trivially_destructible::value) { objStart = this->allocObject(sizeof(T), alignof(T)); -- cgit v1.2.3