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

Commit a04f6995 authored by Santhosh Behara's avatar Santhosh Behara Committed by Robert Shih
Browse files

libmedia: add NULL check before accessing source and destination buffers.

IMemory can return a NULL pointer or the destination buffer for readAt can
be NULL. Check for NULL and report error.

Author:    Shivaprasad Hongal <shongal@codeaurora.org>

Change-Id: I6df9275f2eb9a6e1c2641d084d713b73737d68d7
parent c17c28aa
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -124,6 +124,14 @@ struct BpMediaHTTPConnection : public BpInterface<IMediaHTTPConnection> {
            ALOGE("got %zu, but memory has %zu", len, mMemory->size());
            ALOGE("got %zu, but memory has %zu", len, mMemory->size());
            return ERROR_OUT_OF_RANGE;
            return ERROR_OUT_OF_RANGE;
        }
        }
        if(buffer == NULL) {
           ALOGE("readAt got a NULL buffer");
           return UNKNOWN_ERROR;
        }
        if (mMemory->pointer() == NULL) {
           ALOGE("readAt got a NULL mMemory->pointer()");
           return UNKNOWN_ERROR;
        }


        memcpy(buffer, mMemory->pointer(), len);
        memcpy(buffer, mMemory->pointer(), len);