<div dir="auto"><div>Hi Laurent,<div dir="auto"><br></div><div dir="auto">Thank you for your patch.</div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 12 Dec 2020, 6:51 pm Laurent Pinchart, <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank" rel="noreferrer">laurent.pinchart@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The CameraSensor instance stored in RPiCameraData::sensor_ is allocated<br>
dynamically and never deleted. Fix the memory leak by storing it in a<br>
std::unique_ptr<>.<br>
<br>
Fixes: 740fd1b62f67 ("libcamera: pipeline: Raspberry Pi pipeline handler")<br>
Signed-off-by: Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" rel="noreferrer noreferrer" target="_blank">laurent.pinchart@ideasonboard.com</a>><br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Reviewed-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank" rel="noreferrer">naush@raspberrypi.com</a>></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
 src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 7 ++++---<br>
 1 file changed, 4 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
index 439c21ce4566..7a5f5881b9b3 100644<br>
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
@@ -7,6 +7,7 @@<br>
 #include <algorithm><br>
 #include <assert.h><br>
 #include <fcntl.h><br>
+#include <memory><br>
 #include <mutex><br>
 #include <queue><br>
 #include <sys/mman.h><br>
@@ -134,7 +135,7 @@ class RPiCameraData : public CameraData<br>
 {<br>
 public:<br>
        RPiCameraData(PipelineHandler *pipe)<br>
-               : CameraData(pipe), sensor_(nullptr), state_(State::Stopped),<br>
+               : CameraData(pipe), state_(State::Stopped),<br>
                  supportsFlips_(false), flipsAlterBayerOrder_(false),<br>
                  updateScalerCrop_(true), dropFrameCount_(0), ispOutputCount_(0)<br>
        {<br>
@@ -158,7 +159,7 @@ public:<br>
        void handleState();<br>
        void applyScalerCrop(const ControlList &controls);<br>
<br>
-       CameraSensor *sensor_;<br>
+       std::unique_ptr<CameraSensor> sensor_;<br>
        /* Array of Unicam and ISP device streams and associated buffers/streams. */<br>
        RPi::Device<Unicam, 2> unicam_;<br>
        RPi::Device<Isp, 4> isp_;<br>
@@ -948,7 +949,7 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)<br>
        /* Identify the sensor. */<br>
        for (MediaEntity *entity : unicam_->entities()) {<br>
                if (entity->function() == MEDIA_ENT_F_CAM_SENSOR) {<br>
-                       data->sensor_ = new CameraSensor(entity);<br>
+                       data->sensor_ = std::make_unique<CameraSensor>(entity);<br>
                        break;<br>
                }<br>
        }<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
<br>
</blockquote></div></div></div>