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

Commit b18cfd46 authored by Jayant Chowdhary's avatar Jayant Chowdhary Committed by Android (Google) Code Review
Browse files

Merge "CameraMetadata: avoid memory leak in case allocate_camera_metadata fails." into sc-dev

parents 9a8a479a a94cbe6f
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;
            }
            }