xext: don't free uninitialised pointer when malloc fails. (v2)

Initialise the pAttr->values to values so if the values allocation
fails it just ends up as free(NULL).

Pointed out by coverity.

v2: use Alan's suggestion.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit b62dc4fcbc)
This commit is contained in:
Dave Airlie
2011-10-19 16:21:26 +01:00
committed by Jeremy Huddleston
parent 083599c559
commit b22783f483

View File

@@ -927,7 +927,7 @@ ScreenSaverSetAttributes (ClientPtr client)
goto bail;
}
/* over allocate for override redirect */
values = malloc((len + 1) * sizeof (unsigned long));
pAttr->values = values = malloc((len + 1) * sizeof (unsigned long));
if (!values)
{
ret = BadAlloc;
@@ -947,7 +947,6 @@ ScreenSaverSetAttributes (ClientPtr client)
pAttr->pCursor = NullCursor;
pAttr->pBackgroundPixmap = NullPixmap;
pAttr->pBorderPixmap = NullPixmap;
pAttr->values = values;
/*
* go through the mask, checking the values,
* looking up pixmaps and cursors and hold a reference