OSDN Git Service

sf: Add a NULL check in getDisplayConfigs
authorTatenda Chipeperekwa <tatendac@codeaurora.org>
Wed, 29 Oct 2014 23:47:19 +0000 (16:47 -0700)
committerDan Stoza <stoza@google.com>
Thu, 11 Jun 2015 17:40:21 +0000 (10:40 -0700)
Validate the display binder by adding a NULL check in getDisplayConfigs.
This will prevent a false match if the caller queries the display
configs for an inactive display (whose binder is NULL by default).

Without this change we might end up attempting to index the display
config array, which is unpopulated for inactive displays, and this will
result in a crash. (See getDisplayInfo in SurfaceComposerClient.cpp for
an example of this scenario)

Change-Id: I1a12f43b7c375b9c01998dadd5b658275c733fb2
(cherry picked from commit ac71c26e9180d9d181be5ec9e45da72d39144a8b)

services/surfaceflinger/SurfaceFlinger.cpp

index a426ad6..a332cda 100644 (file)
@@ -550,7 +550,7 @@ bool SurfaceFlinger::authenticateSurfaceTexture(
 
 status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
         Vector<DisplayInfo>* configs) {
-    if (configs == NULL) {
+    if ((configs == NULL) || (display.get() == NULL)) {
         return BAD_VALUE;
     }