Fix nullptr access in GrTextureProvider::createMipMappedTexture

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
This commit is contained in:
bsalomon 2016-03-09 09:52:45 -08:00 committed by Commit bot
parent 2ad1aa67c6
commit 7467ab8cc0

View 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();
}