Remove unsafe align4 call

Align by 4 safely before calling malloc.

BUG=chromium:763972

Change-Id: I9278ae0df516adf3eb96fc390ad7318a47cbefa4
Reviewed-on: https://skia-review.googlesource.com/49760
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2017-09-21 16:20:52 -04:00 committed by Skia Commit-Bot
parent cfbbcbe526
commit 2917e0705e

View File

@ -45,7 +45,14 @@ uint8_t* SkMask::AllocImage(size_t size) {
#ifdef TRACK_SKMASK_LIFETIME
SkDebugf("SkMask::AllocImage %d\n", gCounter++);
#endif
return (uint8_t*)sk_malloc_throw(SkAlign4(size));
size_t aligned_size = std::numeric_limits<size_t>::max();
// Expand size to next multiple of four.
size_t adjustment = 3;
if (size + adjustment > size) {
aligned_size = (size + adjustment) & ~adjustment;
}
return static_cast<uint8_t*>(sk_malloc_throw(aligned_size));
}
/** We explicitly use this allocator for SkBimap pixels, so that we can