summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-08 16:44:32 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-10 15:28:04 +0200
commit824ed85553cf65ba879b03e326c8647619d7ede1 (patch)
treef5dba98e6d2405b3099004cd21997b02655de0a9
parent93a037efff7b8afd04aad76f6b6a4514acb6f670 (diff)
libcamera: device_enumerator: Fix memory leak in error path
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@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
-rw-r--r--src/libcamera/device_enumerator.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp
index f1d016db..0d18e755 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.