Fix nullptr access in GrTextureProvider::createMipMappedTexture
authorbsalomon <bsalomon@google.com>
Wed, 9 Mar 2016 17:52:45 +0000 (09:52 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 9 Mar 2016 17:52:45 +0000 (09:52 -0800)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1777013002

Review URL: https://codereview.chromium.org/1777013002

src/gpu/GrTextureProvider.cpp

index f1775ab..3596ba6 100644 (file)
@@ -53,12 +53,12 @@ GrTexture* GrTextureProvider::createMipMappedTexture(const GrSurfaceDesc& desc,
     if (!GrPixelConfigIsCompressed(desc.fConfig) &&
         !desc.fTextureStorageAllocator.fAllocateTextureStorage) {
         if (mipLevelCount < 2) {
-            const GrMipLevel& baseMipLevel = texels[0];
             static const uint32_t kFlags = kExact_ScratchTextureFlag |
                                            kNoCreate_ScratchTextureFlag;
             if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) {
-                if (!texels || texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
-                                                    baseMipLevel.fPixels, baseMipLevel.fRowBytes)) {
+                if (!mipLevelCount ||
+                    texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
+                                         texels[0].fPixels, texels[0].fRowBytes)) {
                     if (SkBudgeted::kNo == budgeted) {
                         texture->resourcePriv().makeUnbudgeted();
                     }