OSDN Git Service

libmedia: add NULL check before accessing source and destination buffers.
authorSanthosh Behara <santhoshbehara@codeaurora.org>
Wed, 4 Nov 2015 21:20:52 +0000 (13:20 -0800)
committerRobert Shih <robertshih@google.com>
Tue, 14 Feb 2017 00:49:29 +0000 (16:49 -0800)
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

media/libmedia/IMediaHTTPConnection.cpp

index e4b717b..1bb8d67 100644 (file)
@@ -124,6 +124,14 @@ struct BpMediaHTTPConnection : public BpInterface<IMediaHTTPConnection> {
             ALOGE("got %zu, but memory has %zu", len, mMemory->size());
             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);