From 9b8f4c870fa831c4c4becd4226a2eccfc84f5110 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 23 Sep 2021 14:49:46 +0300 Subject: android: camera_device: Return unique_ptr from createFrameBuffer Returning a non-managed pointer can cause leaks. Use a unique_ptr<> instead to avoid possible future issues. The std::move() for the planes argument to the FrameBuffer constructor is dropped as it's misleading. FrameBuffer has no constructor that takes an rvalue reference to planes, so the vector was copied despite the move. This only clarifies the intent, no functional change is introduced. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Hirokazu Honda Reviewed-by: Umang Jain Reviewed-by: Paul Elder --- src/android/camera_device.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/android/camera_device.h') diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 296c2f18..43eb5895 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -94,9 +94,10 @@ private: void stop(); - libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer, - libcamera::PixelFormat pixelFormat, - const libcamera::Size &size); + std::unique_ptr + createFrameBuffer(const buffer_handle_t camera3buffer, + libcamera::PixelFormat pixelFormat, + const libcamera::Size &size); void abortRequest(camera3_capture_request_t *request); bool isValidRequest(camera3_capture_request_t *request) const; void notifyShutter(uint32_t frameNumber, uint64_t timestamp); -- cgit v1.2.1