Fix leak in SkImage_Gpu::onMakeSubset().
authorsenorblanco <senorblanco@chromium.org>
Fri, 20 May 2016 14:27:38 +0000 (07:27 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 20 May 2016 14:27:38 +0000 (07:27 -0700)
BUG=skia:5327
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2003573002

Review-Url: https://codereview.chromium.org/2003573002

src/image/SkImage_Gpu.cpp

index 2c2405839529f7aa27ffcef65536495542bd0490..f026ebcb378c89740bf8dcf1f82cee98a2566991 100644 (file)
@@ -140,13 +140,13 @@ sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const {
     desc.fWidth = subset.width();
     desc.fHeight = subset.height();
 
-    GrTexture* subTx = ctx->textureProvider()->createTexture(desc, fBudgeted);
+    sk_sp<GrTexture> subTx(ctx->textureProvider()->createTexture(desc, fBudgeted));
     if (!subTx) {
         return nullptr;
     }
-    ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0));
+    ctx->copySurface(subTx.get(), fTexture, subset, SkIPoint::Make(0, 0));
     return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID,
-                                   fAlphaType, subTx, fBudgeted);
+                                   fAlphaType, subTx.get(), fBudgeted);
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////