[PATCH 2/5] xext: don't free uninitialised pointer when malloc fails.

Jeremy Huddleston jeremyhu at apple.com
Wed Oct 19 10:36:53 PDT 2011


I actually prefer Alan's suggestion, so with his version:

Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

On Oct 19, 2011, at 9:51 AM, Alan Coopersmith wrote:

> On 10/19/11 09:01, Dave Airlie wrote:
>> From: Dave Airlie<airlied at redhat.com>
>> 
>> Initialise the pAttr->values to NULL so if the values allocation
>> fails it just ends up as free(NULL).
>> 
>> Pointed out by coverity.
>> 
>> Signed-off-by: Dave Airlie<airlied at redhat.com>
>> ---
>>  Xext/saver.c |    1 +
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>> 
>> diff --git a/Xext/saver.c b/Xext/saver.c
>> index 142758c..c6bcafa 100644
>> --- a/Xext/saver.c
>> +++ b/Xext/saver.c
>> @@ -925,6 +925,7 @@ ScreenSaverSetAttributes (ClientPtr client)
>>  	goto bail;
>>      }
>>      /* over allocate for override redirect */
>> +    pAttr->values = NULL;
>>      values = malloc((len + 1) * sizeof (unsigned long));
>>      if (!values)
>>      {
> 
> Could also just be done by:
> 
>    pAttr->values = values = malloc((len + 1) * sizeof (unsigned long));
> 
> and then not needing the later pAttr->values = values, but either way,
> seems like a needed fix, so:
> 
> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> 
> -- 
> 	-Alan Coopersmith-        alan.coopersmith at oracle.com
> 	 Oracle Solaris Platform Engineering: X Window System
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 



More information about the xorg-devel mailing list