fail on bad size or firstHeapAllocation creating GrSubRunAllocator

Double check sizes coming into sub run allocator.

Bug: oss-fuzz:45638

Change-Id: Ice9ab49dc0af789bf59efde270024321c5cf0f28
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/521836
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2022-03-17 08:52:01 -04:00 committed by SkCQ
parent 91b5f668e8
commit b8811727e8

View File

@ -77,10 +77,13 @@ void GrBagOfBytes::needMoreBytes(int requestedSize, int alignment) {
// -- GrSubRunAllocator ----------------------------------------------------------------------------
GrSubRunAllocator::GrSubRunAllocator(char* bytes, int size, int firstHeapAllocation)
: fAlloc{bytes, SkTo<size_t>(size), SkTo<size_t>(firstHeapAllocation)} {}
: fAlloc{bytes, SkTo<size_t>(size), SkTo<size_t>(firstHeapAllocation)} {
SkASSERT_RELEASE(SkTFitsIn<size_t>(size));
SkASSERT_RELEASE(SkTFitsIn<size_t>(firstHeapAllocation));
}
GrSubRunAllocator::GrSubRunAllocator(int firstHeapAllocation)
: GrSubRunAllocator(nullptr, 0, firstHeapAllocation) {}
: GrSubRunAllocator(nullptr, 0, firstHeapAllocation) { }
void* GrSubRunAllocator::alignedBytes(int unsafeSize, int unsafeAlignment) {
return fAlloc.alignedBytes(unsafeSize, unsafeAlignment);