Fix leak of backend texture in GrContext_maxSurfaceSamplesForColorType test
Bug: skia:7729
Change-Id: I0e946f15e16a7f4e42d862ac468323f29d65357a
Reviewed-on: https://skia-review.googlesource.com/116182
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index bd3090c..e74dcc9 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -191,7 +191,10 @@
auto* gpu = ctxInfo.grContext()->contextPriv().getGpu();
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
nullptr, kSize, kSize, colorType, true, GrMipMapped::kNo);
-
+ if (!backendTex.isValid()) {
+ continue;
+ }
+ SkScopeExit freeTex([&backendTex, gpu] {gpu->deleteTestingOnlyBackendTexture(backendTex);});
auto info = SkImageInfo::Make(kSize, kSize, colorType, kOpaque_SkAlphaType, nullptr);
auto surf = SkSurface::MakeFromBackendTexture(ctxInfo.grContext(), backendTex,
kTopLeft_GrSurfaceOrigin, max,