[libcamera-devel] [PATCH] libcamera: device_enumerator: Fix memory leak in error path

Niklas Söderlund niklas.soderlund at ragnatech.se
Wed Jan 9 16:40:01 CET 2019


Hi Laurent,

Thanks for fixing my mistake :-)

On 2019-01-08 16:46:21 +0200, Laurent Pinchart wrote:
> 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>

Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>

> ---
>  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
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

-- 
Regards,
Niklas Söderlund


More information about the libcamera-devel mailing list