diff options
author | 2013-05-28 13:13:56 +0000 | |
---|---|---|
committer | 2013-05-28 13:13:56 +0000 | |
commit | c7d624ec535adcc388cad35b3475872b08cd90c0 (patch) | |
tree | 9b267d1a2882fc76ec37bece7f0b0955c5b82fc0 /src/effects | |
parent | 454ae46814541cb10ee72217ef4102869254f7eb (diff) |
check texture is not NULL to aovid segmentation fault. If the texture created by GrLockAndRefCachedBitmapTexture() is NULL, ColorTableEffect::Create will cause segmentation fault by GrAssert in src/gpu/GrTextureAccess.cpp. The simple patch checked texture to avoid segment fault, and returned a NULL effect to the caller. The caller will handle NULL effect, for example, it will set default effect.
R=bsalomon@google.com, robertphillips@google.com
Author: yunchao.he@intel.com
Review URL: https://chromiumcodereview.appspot.com/15824003
git-svn-id: http://skia.googlecode.com/svn/trunk@9287 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkTableColorFilter.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index 2c452ff9f7..cbcc6bc439 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -386,15 +386,18 @@ GrEffectRef* ColorTableEffect::TestCreate(SkMWCRandom* random, GrEffectRef* SkTable_ColorFilter::asNewEffect(GrContext* context) const { SkBitmap bitmap; + GrEffectRef* effect = NULL; this->asComponentTable(&bitmap); // passing NULL because this effect does no tiling or filtering. GrTexture* texture = GrLockAndRefCachedBitmapTexture(context, bitmap, NULL); - GrEffectRef* effect = ColorTableEffect::Create(texture, fFlags); + if (NULL != texture) { + effect = ColorTableEffect::Create(texture, fFlags); - // Unlock immediately, this is not great, but we don't have a way of - // knowing when else to unlock it currently. TODO: Remove this when - // unref becomes the unlock replacement for all types of textures. - GrUnlockAndUnrefCachedBitmapTexture(texture); + // Unlock immediately, this is not great, but we don't have a way of + // knowing when else to unlock it currently. TODO: Remove this when + // unref becomes the unlock replacement for all types of textures. + GrUnlockAndUnrefCachedBitmapTexture(texture); + } return effect; } |