summaryrefslogtreecommitdiff
path: root/randr
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-10 23:29:53 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2012-08-06 15:22:53 -0700
commit42e655de4d95cb108aec50efec6bbdb709bb13d7 (patch)
treeabad3c793e6b2b64674f2bc4dd24d2d1a67720df /randr
parent94b514d5e4b376d05e106eb3853da511256e8545 (diff)
rrproviderproperty.c: free newly allocated prop in more error paths
Reported by parfait 1.0: Error: Memory leak (CWE 401) Memory leak of pointer 'prop' allocated with RRCreateProviderProperty(property) at line 221 of randr/rrproviderproperty.c in function 'RRChangeProviderProperty'. 'prop' allocated at line 155 with RRCreateProviderProperty(property). prop leaks when pending != 0 at line 161. Error: Memory leak (CWE 401) Memory leak of pointer 'prop' allocated with RRCreateProviderProperty(property) at line 345 of randr/rrproviderproperty.c in function 'RRConfigureProviderProperty'. 'prop' allocated at line 333 with RRCreateProviderProperty(property). at line 349 of randr/rrproviderproperty.c in function 'RRConfigureProviderProperty'. 'prop' allocated at line 333 with RRCreateProviderProperty(property). Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'randr')
-rw-r--r--randr/rrproviderproperty.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c
index e0a814ff8..ab601da9a 100644
--- a/randr/rrproviderproperty.c
+++ b/randr/rrproviderproperty.c
@@ -216,6 +216,8 @@ RRChangeProviderProperty(RRProviderPtr provider, Atom property, Atom type,
if (pending && pScrPriv->rrProviderSetProperty &&
!pScrPriv->rrProviderSetProperty(provider->pScreen, provider,
prop->propertyName, &new_value)) {
+ if (add)
+ RRDestroyProviderProperty(prop);
free(new_value.data);
return BadValue;
}
@@ -342,12 +344,18 @@ RRConfigureProviderProperty(RRProviderPtr provider, Atom property,
/*
* ranges must have even number of values
*/
- if (range && (num_values & 1))
+ if (range && (num_values & 1)) {
+ if (add)
+ RRDestroyProviderProperty(prop);
return BadMatch;
+ }
new_values = malloc(num_values * sizeof(INT32));
- if (!new_values && num_values)
+ if (!new_values && num_values) {
+ if (add)
+ RRDestroyProviderProperty(prop);
return BadAlloc;
+ }
if (num_values)
memcpy(new_values, values, num_values * sizeof(INT32));