fix build
[LibreOffice.git] / external / skia / 0001-AvoidCombiningExtrememelyLargeMeshes.patch.1
blobca58048a75f093c78d5c9224cd90d1f9ec23bca8
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.
6 Bug: chromium:1505053
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>
12 ---
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;
22      }
24 +    if (fVertexCount > INT32_MAX - that->fVertexCount) {
25 +        return CombineResult::kCannotCombine;
26 +    }
27      if (SkToBool(fIndexCount) != SkToBool(that->fIndexCount)) {
28          return CombineResult::kCannotCombine;
29      }
30 -    if (SkToBool(fIndexCount) && fVertexCount + that->fVertexCount > SkToInt(UINT16_MAX)) {
31 +    if (SkToBool(fIndexCount) && fVertexCount > UINT16_MAX - that->fVertexCount) {
32          return CombineResult::kCannotCombine;
33      }