Skip to content

Commit acb73db

Browse files
Chong Zhangandi34
authored andcommitted
stagefright: check IMemory::pointer() before using the allocation
bug: 19779574 Change-Id: I4ffe8c3fadc07da211f421e75ee83010b01d9cbb (cherry picked from commit 8ec845c)
1 parent 0269d9c commit acb73db

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

media/libstagefright/ACodec.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,9 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) {
499499

500500
for (OMX_U32 i = 0; i < def.nBufferCountActual; ++i) {
501501
sp<IMemory> mem = mDealer[portIndex]->allocate(def.nBufferSize);
502-
CHECK(mem.get() != NULL);
502+
if (mem == NULL || mem->pointer() == NULL) {
503+
return NO_MEMORY;
504+
}
503505

504506
BufferInfo info;
505507
info.mStatus = BufferInfo::OWNED_BY_US;
@@ -756,7 +758,9 @@ status_t ACodec::allocateOutputMetaDataBuffers() {
756758

757759
sp<IMemory> mem = mDealer[kPortIndexOutput]->allocate(
758760
sizeof(struct VideoDecoderOutputMetaData));
759-
CHECK(mem.get() != NULL);
761+
if (mem == NULL || mem->pointer() == NULL) {
762+
return NO_MEMORY;
763+
}
760764
info.mData = new ABuffer(mem->pointer(), mem->size());
761765

762766
// we use useBuffer for metadata regardless of quirks

0 commit comments

Comments
 (0)