diff --git a/src/gpu/ganesh/ops/DrawAtlasOp.cpp b/src/gpu/ganesh/ops/DrawAtlasOp.cpp index 776587d3e29112187056939f4a7902b7174a1ad9..719d7fa0b8edd03e0fd53881a6939e061a3290b5 100644 --- a/src/gpu/ganesh/ops/DrawAtlasOp.cpp +++ b/src/gpu/ganesh/ops/DrawAtlasOp.cpp @@ -112,7 +112,7 @@ DrawAtlasOpImpl::DrawAtlasOpImpl(GrProcessorSet* processorSet, const SkPMColor4f : GrMeshDrawOp(ClassID()), fHelper(processorSet, aaType), fColor(color) { SkASSERT(xforms); SkASSERT(rects); - + SkASSERT(spriteCount >= 0); fViewMatrix = viewMatrix; Geometry& installedGeo = fGeoData.push_back(); installedGeo.fColor = color; @@ -127,6 +127,11 @@ DrawAtlasOpImpl::DrawAtlasOpImpl(GrProcessorSet* processorSet, const SkPMColor4f vertexStride += sizeof(GrColor); } + // Bail out if we'd overflow from a really large draw + if (spriteCount > SK_MaxS32 / static_cast(4 * vertexStride)) { + return; + } + // Compute buffer size and alloc buffer fQuadCount = spriteCount; int allocSize = static_cast(4 * vertexStride * spriteCount);