OSDN Git Service

MediaRecorderClient: Fix binder dereference while connecting to camera
authorMahesh Lanka <mlanka@codeaurora.org>
Tue, 31 Jan 2017 12:52:57 +0000 (18:22 +0530)
committerWonsik Kim <wonsik@google.com>
Mon, 20 Mar 2017 17:43:45 +0000 (10:43 -0700)
IServiceManager.getService can return NULL. Check for NULL and
return NO_INIT on failure.

Bug: 34870127
Test: adb shell am instrument -e size small -w 'android.media.cts/android.support.test.runner.AndroidJUnitRunner'
Change-Id: I6d71f8c0e89a556e64f5250ba1ab742e485f1ebc

media/libmediaplayerservice/MediaRecorderClient.cpp

index c00a951..638eec3 100644 (file)
@@ -465,6 +465,10 @@ status_t MediaRecorderClient::setListener(const sp<IMediaRecorderClient>& listen
     } else {
         // Legacy IOMX
         binder = sm->getService(String16("media.codec"));
+        if (binder == NULL) {
+           ALOGE("Unable to connect to media codec service");
+           return NO_INIT;
+        }
         mCodecDeathListener = new ServiceDeathNotifier(binder, listener,
                 MediaPlayerService::MEDIACODEC_PROCESS_DEATH);
         binder->linkToDeath(mCodecDeathListener);