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

Commit 1f44bfba authored by Chong Zhang's avatar Chong Zhang
Browse files

Handle nullptr if memory allocation fails

bug: 182317379
test: MediaMetadataRetrieverTest
Change-Id: I454f1301567762eea11d194852a814972ca8dd9f
parent da52d866
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -644,6 +644,10 @@ status_t VideoFrameDecoder::onOutputReceived(
                0,
                dstBpp(),
                mCaptureLayer != nullptr /*allocRotated*/);
        if (frameMem == nullptr) {
            return NO_MEMORY;
        }

        mFrame = static_cast<VideoFrame*>(frameMem->unsecurePointer());

        setFrame(frameMem);
@@ -886,6 +890,11 @@ status_t ImageDecoder::onOutputReceived(
    if (mFrame == NULL) {
        sp<IMemory> frameMem = allocVideoFrame(
                trackMeta(), mWidth, mHeight, mTileWidth, mTileHeight, dstBpp());

        if (frameMem == nullptr) {
            return NO_MEMORY;
        }

        mFrame = static_cast<VideoFrame*>(frameMem->unsecurePointer());

        setFrame(frameMem);