[PATCH] XIChangeDeviceProperty: free newly allocated prop when SetProperty fails
Peter Hutterer
peter.hutterer at who-t.net
Tue Jul 31 18:59:52 PDT 2012
On Mon, Jul 30, 2012 at 11:37:06PM -0700, Alan Coopersmith wrote:
> Reported by parfait 1.0:
>
> Error: Memory leak (CWE 401)
> Memory leak of pointer 'prop' allocated with XICreateDeviceProperty(property)
> at line 774 of Xi/xiproperty.c in function 'XIChangeDeviceProperty'.
> 'prop' allocated at line 700 with XICreateDeviceProperty(property).
> prop leaks when handler != NULL at line 768
> and handler->SetProperty != NULL at line 769
> and checkonly != 0 at line 772
> and rc != 0 at line 772.
>
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
applied, thanks.
> ---
> Xi/xiproperty.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
> index ca73104..4beedcf 100644
> --- a/Xi/xiproperty.c
> +++ b/Xi/xiproperty.c
> @@ -771,6 +771,8 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
> &new_value, checkonly);
> if (checkonly && rc != Success) {
> free(new_value.data);
> + if (add)
> + XIDestroyDeviceProperty(prop);
> return rc;
> }
> }
> --
> 1.7.9.2
>
More information about the xorg-devel
mailing list