Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34732806 authored by Karthikeyan Periasamy's avatar Karthikeyan Periasamy
Browse files

MediaRecorderClient: Fix binder dereference while connecting to camera

IServiceManager.getService can return NULL. Check for NULL and
return NO_INIT on failure.

Change-Id: Ief63edb78bdcf845a5b1ed1fe05cc012a466afff
CRs-Fixed: 1059552
parent e0b0a36e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -371,11 +371,21 @@ status_t MediaRecorderClient::setListener(const sp<IMediaRecorderClient>& listen

    sp<IServiceManager> sm = defaultServiceManager();
    sp<IBinder> binder = sm->getService(String16("media.camera"));
    if (binder == NULL) {
        ALOGE("Unable to connect to camera service");
        return NO_INIT;
    }

    mCameraDeathListener = new ServiceDeathNotifier(binder, listener,
            MediaPlayerService::CAMERA_PROCESS_DEATH);
    binder->linkToDeath(mCameraDeathListener);

    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);