[libcamera-devel] [PATCH] libcamera: device_enumerator: Fix memory leak in error path
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Jan 8 15:46:21 CET 2019
The DeviceEnumerator::create() function allocates a
DeviceEnumeratorUdev and fails to delete it in the error path, causing a
memory leak. Fix it.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
src/libcamera/device_enumerator.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp
index f1d016db64a0..0d18e75525af 100644
--- a/src/libcamera/device_enumerator.cpp
+++ b/src/libcamera/device_enumerator.cpp
@@ -140,6 +140,8 @@ DeviceEnumerator *DeviceEnumerator::create()
if (!enumerator->init())
return enumerator;
+ delete enumerator;
+
/*
* Either udev is not available or udev initialization failed. Fall back
* on the sysfs enumerator.
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list