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

Commit a73342bb authored by Karthikeyan Periasamy's avatar Karthikeyan Periasamy Committed by Gerrit - the friendly Code Review server
Browse files

MediaPlayerService: Fix binder dereference while connecting to media services

IServiceManager.getService can return NULL. Accessing binder object without
checking will cause a crash when ServiceManager fails to find the media services.

Check for NULL and return NO_INIT on failure.

CRs-Fixed: 1064299
Change-Id: Ic8e03d40d60af13d98badb14a8e8d37dab38c001
parent c6f2b040
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -685,10 +685,20 @@ sp<MediaPlayerBase> MediaPlayerService::Client::setDataSource_pre(

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

    mExtractorDeathListener = new ServiceDeathNotifier(binder, p, MEDIAEXTRACTOR_PROCESS_DEATH);
    binder->linkToDeath(mExtractorDeathListener);

    binder = sm->getService(String16("media.codec"));
    if (binder == NULL) {
        ALOGE("Unable to connect to media codec service");
        return NULL;
    }

    mCodecDeathListener = new ServiceDeathNotifier(binder, p, MEDIACODEC_PROCESS_DEATH);
    binder->linkToDeath(mCodecDeathListener);