summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorBo Liu <boliu@google.com>2014-11-24 10:53:52 -0800
committerBo Liu <boliu@google.com>2014-11-24 11:25:45 -0800
commitde92f4c72be8537d2efff6024390b9ab706286e1 (patch)
tree63a7902d20b162c6293a198c3d1ce297186e3ce2 /core/jni
parentb5686d55963e76c801ca0581a1012c5f4aa8d009 (diff)
downloadframeworks_base-de92f4c72be8537d2efff6024390b9ab706286e1.zip
frameworks_base-de92f4c72be8537d2efff6024390b9ab706286e1.tar.gz
frameworks_base-de92f4c72be8537d2efff6024390b9ab706286e1.tar.bz2
Fix crash in getNativeCanvas when canvasHandle is NULL
BUG: 18261928 Change-Id: I01a5af201fe829d5752433e1bb0db7edc01733d4
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android/graphics/Graphics.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index d7b75db..2eccfbd 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -365,6 +365,9 @@ SkCanvas* GraphicsJNI::getNativeCanvas(JNIEnv* env, jobject canvas) {
SkASSERT(canvas);
SkASSERT(env->IsInstanceOf(canvas, gCanvas_class));
jlong canvasHandle = env->GetLongField(canvas, gCanvas_nativeInstanceID);
+ if (!canvasHandle) {
+ return NULL;
+ }
SkCanvas* c = reinterpret_cast<android::Canvas*>(canvasHandle)->getSkCanvas();
SkASSERT(c);
return c;