XIChangeDeviceProperty: free newly allocated prop when SetProperty fails

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@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Alan Coopersmith 2012-07-30 23:37:06 -07:00 committed by Peter Hutterer
parent 4dbbcdf645
commit 7328900042

View File

@ -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;
}
}