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

Alan Coopersmith alan.coopersmith at oracle.com
Wed Oct 19 09:51:36 PDT 2011


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



More information about the xorg-devel mailing list