[libcamera-devel] [PATCH 03/14] libcamera: bound_method: Fix memory leak with direct connections

Niklas Söderlund niklas.soderlund at ragnatech.se
Tue Jan 7 20:00:02 CET 2020


Hi Laurent,

Thanks for your work.

On 2020-01-04 07:09:36 +0200, Laurent Pinchart wrote:
> When BoundMethodBase::activatePack() is called with the connection type
> set to ConnectionTypeDirect, the method isn't deleted even if
> deleteMethod is true, as is the case when called from
> Object::invokeMethod(). This causes 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/bound_method.cpp | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/libcamera/bound_method.cpp b/src/libcamera/bound_method.cpp
> index 4c0cd415a3f1..45c765774801 100644
> --- a/src/libcamera/bound_method.cpp
> +++ b/src/libcamera/bound_method.cpp
> @@ -62,6 +62,8 @@ void BoundMethodBase::activatePack(void *pack, bool deleteMethod)
>  	case ConnectionTypeDirect:
>  	default:
>  		invokePack(pack);
> +		if (deleteMethod)
> +			delete this;
>  		break;
>  
>  	case ConnectionTypeQueued: {
> -- 
> 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