Guard against instantiate & accessRenderTarget failures
Chrome's fuzzer have reminded me that, since we are deferring allocation, instantiate and accessRenderTarget can now fail further down the call stack.
This should probably be cherry picked back to M56.
BUG=665681,665500,665621
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4929
Change-Id: I44d81ff29586dfe75ddda30b5ed8ca76354542d6
Reviewed-on: https://skia-review.googlesource.com/4929
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index f188781..c97eb01 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -390,6 +390,9 @@
// TODO: add GrTextureProxy-backed SkImage_Gpus
GrSurface* surf = fSurfaceProxy->instantiate(fContext->textureProvider());
+ if (!surf) {
+ return;
+ }
// TODO: In this instance we know we're going to draw a sub-portion of the backing
// texture into the canvas so it is okay to wrap it in an SkImage. This poses
@@ -411,7 +414,9 @@
// This entry point should go away in favor of asTextureProxy
sk_sp<GrTexture> onAsTextureRef(GrContext* context) const override {
GrSurface* surf = fSurfaceProxy->instantiate(context->textureProvider());
-
+ if (!surf) {
+ return nullptr;
+ }
return sk_ref_sp(surf->asTexture());
}
@@ -436,6 +441,9 @@
// Reading back to an SkBitmap ends deferral
GrSurface* surface = fSurfaceProxy->instantiate(fContext->textureProvider());
+ if (!surface) {
+ return false;
+ }
if (!surface->readPixels(0, 0, dst->width(), dst->height(), kSkia8888_GrPixelConfig,
dst->getPixels(), dst->rowBytes())) {
@@ -477,6 +485,9 @@
sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override {
// TODO: add GrTextureProxy-backed SkImage_Gpus
GrSurface* surf = fSurfaceProxy->instantiate(fContext->textureProvider());
+ if (!surf) {
+ return nullptr;
+ }
if (0 == subset.fLeft && 0 == subset.fTop &&
fSurfaceProxy->width() == subset.width() &&