1 From 6169a1fabae1743709bc9641ad43fcbb6a4f62e1 Mon Sep 17 00:00:00 2001
2 From: John Stiles <johnstiles@google.com>
3 Date: Fri, 24 Nov 2023 09:40:11 -0500
4 Subject: [PATCH] Avoid combining extremely large meshes.
7 Change-Id: I42f2ff872bbf054686ec7af0cc85ff63055fcfbf
8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/782936
9 Commit-Queue: Michael Ludwig <michaelludwig@google.com>
10 Reviewed-by: Michael Ludwig <michaelludwig@google.com>
11 Auto-Submit: John Stiles <johnstiles@google.com>
13 src/gpu/ganesh/ops/DrawMeshOp.cpp | 5 ++++-
14 1 file changed, 4 insertions(+), 1 deletion(-)
16 diff --git a/src/gpu/ganesh/ops/DrawMeshOp.cpp b/src/gpu/ganesh/ops/DrawMeshOp.cpp
17 index d827009b993..eed2757579e 100644
18 --- a/src/gpu/ganesh/ops/DrawMeshOp.cpp
19 +++ b/src/gpu/ganesh/ops/DrawMeshOp.cpp
20 @@ -1178,10 +1178,13 @@ GrOp::CombineResult MeshOp::onCombineIfPossible(GrOp* t, SkArenaAlloc*, const Gr
21 return CombineResult::kCannotCombine;
24 + if (fVertexCount > INT32_MAX - that->fVertexCount) {
25 + return CombineResult::kCannotCombine;
27 if (SkToBool(fIndexCount) != SkToBool(that->fIndexCount)) {
28 return CombineResult::kCannotCombine;
30 - if (SkToBool(fIndexCount) && fVertexCount + that->fVertexCount > SkToInt(UINT16_MAX)) {
31 + if (SkToBool(fIndexCount) && fVertexCount > UINT16_MAX - that->fVertexCount) {
32 return CombineResult::kCannotCombine;