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

Commit a94cbe6f authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

CameraMetadata: avoid memory leak in case allocate_camera_metadata fails.



Bug: 186686705

Test: Native camera cts tests (basic validity)

Change-Id: I68339109d1f33facdab7ad8b689624f987cb274e
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent a1335e1a
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -528,6 +528,8 @@ status_t CameraMetadata::resizeIfNeeded(size_t extraEntries, size_t extraData) {
            mBuffer = allocate_camera_metadata(newEntryCount,
            mBuffer = allocate_camera_metadata(newEntryCount,
                    newDataCount);
                    newDataCount);
            if (mBuffer == NULL) {
            if (mBuffer == NULL) {
                // Maintain old buffer to avoid potential memory leak.
                mBuffer = oldBuffer;
                ALOGE("%s: Can't allocate larger metadata buffer", __FUNCTION__);
                ALOGE("%s: Can't allocate larger metadata buffer", __FUNCTION__);
                return NO_MEMORY;
                return NO_MEMORY;
            }
            }