frameworks/base
Revision | 97d43a228f365005b46f3419ce94d13a83334007 (tree) |
---|---|
Time | 2020-04-14 23:46:55 |
Author | Mauro Rossi <issor.oruam@gmai...> |
Commiter | Chih-Wei Huang |
android_view_ThreadedRenderer: prevent Null Pointer Exception in createBitmap
To avoid Playstore crashes with nouveau and Hardware Bitmap,
a check is added to bitmap returned by Bitmap::createFrom(buffer)
inspired by similar behavior in Bitmap.cpp Bitmap_createHardwareBitmap()
Fixes the following crash:
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Android-x86/android_x86/x86:8.1.0/OPM8.181005.003/uten01131829:userdebug/test-keys'
Revision: '0'
ABI: 'x86'
pid: 4644, tid: 4644, name: android.vending >>> com.android.vending <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xc
Cause: null pointer dereference
backtrace:
@@ -992,6 +992,10 @@ static jobject android_view_ThreadedRenderer_createHardwareBitmapFromRenderNode( | ||
992 | 992 | cs = SkColorSpace::MakeSRGB(); |
993 | 993 | } |
994 | 994 | sk_sp<Bitmap> bitmap = Bitmap::createFrom(buffer, ct, cs); |
995 | + if (!bitmap.get()) { | |
996 | + ALOGW("Failed to create hardware bitmap from graphic buffer"); | |
997 | + return nullptr; | |
998 | + } | |
995 | 999 | return bitmap::createBitmap(env, bitmap.release(), |
996 | 1000 | android::bitmap::kBitmapCreateFlag_Premultiplied); |
997 | 1001 | } |