Add checks for TextureSampler count in text GeoProcs.
Chrome is seeing unexplained segfaults when trying to access the n-1th
textureSampler while creating textOp GeoProcs -- it's possible that's
because n is 0. Also add checks to make sure n is not > kMaxTextures.
Bug: chromium:1027314
Change-Id: I65a5472980bab37d580b3f237a132a8b23794abe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255985
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index c33b4d3..8a2dfbb 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -411,6 +411,10 @@
unsigned int numActiveProxies;
const sk_sp<GrTextureProxy>* proxies = atlasManager->getProxies(maskFormat, &numActiveProxies);
SkASSERT(proxies);
+ // Something has gone terribly wrong, bail
+ if (!proxies || 0 == numActiveProxies) {
+ return;
+ }
if (gp->numTextureSamplers() != (int) numActiveProxies) {
// During preparation the number of atlas pages has increased.
// Update the proxies used in the GP to match.