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

Commit 5353a502 authored by Shivaprasad Hongal's avatar Shivaprasad Hongal Committed by Linux Build Service Account
Browse files

libstagefright/omx: Fix CallbackDispatcher dereference in callback.

findDispatcher can return NULL. Check for NULL

Change-Id: I07edc427b706dfdeec6a6f90f13d00c8941e77f2
parent b6a9f8c1
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -652,6 +652,10 @@ OMX_ERRORTYPE OMX::OnEvent(
    instance->onEvent(eEvent, nData1, nData2);

    sp<OMX::CallbackDispatcher> dispatcher = findDispatcher(node);
    if (dispatcher == NULL) {
       ALOGW("OnEvent Callback dispatcher NULL, skip post");
       return OMX_ErrorNone;
    }

    // output rendered events are not processed as regular events until they hit the observer
    if (eEvent == OMX_EventOutputRendered) {
@@ -697,7 +701,12 @@ OMX_ERRORTYPE OMX::OnEmptyBufferDone(
    msg.fenceFd = fenceFd;
    msg.u.buffer_data.buffer = buffer;

    findDispatcher(node)->post(msg);
    sp<OMX::CallbackDispatcher> callbackDispatcher = findDispatcher(node);
    if (callbackDispatcher != NULL) {
        callbackDispatcher->post(msg);
    } else {
        ALOGW("OnEmptyBufferDone Callback dispatcher NULL, skip post");
    }

    return OMX_ErrorNone;
}
@@ -716,7 +725,12 @@ OMX_ERRORTYPE OMX::OnFillBufferDone(
    msg.u.extended_buffer_data.flags = pBuffer->nFlags;
    msg.u.extended_buffer_data.timestamp = pBuffer->nTimeStamp;

    findDispatcher(node)->post(msg);
    sp<OMX::CallbackDispatcher> callbackDispatcher = findDispatcher(node);
    if (callbackDispatcher != NULL) {
        callbackDispatcher->post(msg);
    } else {
        ALOGW("OnFillBufferDone Callback dispatcher NULL, skip post");
    }

    return OMX_ErrorNone;
}