From c4ec816a89c0f39f1b2dfb507f7c8cf39b4e1eae Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Thu, 5 Apr 2018 11:43:31 -0400 Subject: replace size-alignment assert with round-down Don't need to assert here, we just won't write into all of the external memory if its length is not a multiple of what we need. Bug: skia: Change-Id: I277653f5dc3b3d7560ab71a10440275f55430833 Reviewed-on: https://skia-review.googlesource.com/118884 Reviewed-by: Mike Klein Commit-Queue: Mike Reed --- src/core/SkWriter32.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/SkWriter32.h b/src/core/SkWriter32.h index 1e004a8b1d..2143c6b129 100644 --- a/src/core/SkWriter32.h +++ b/src/core/SkWriter32.h @@ -47,8 +47,10 @@ public: size_t size() const { return this->bytesWritten(); } void reset(void* external = nullptr, size_t externalBytes = 0) { + // we cast this pointer to int* and float* at times, so assert that it is aligned. SkASSERT(SkIsAlign4((uintptr_t)external)); - SkASSERT(SkIsAlign4(externalBytes)); + // we always write multiples of 4-bytes, so truncate down the size to match that + externalBytes &= ~3; fData = (uint8_t*)external; fCapacity = externalBytes; -- cgit v1.2.3