uxa: Fix reallocation of XVAdaptors array

Prevent the leak and remove some unsightly code in the process.

Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2012-06-01 23:22:31 +01:00
parent affb1f82c1
commit ba0eb23083
1 changed files with 5 additions and 6 deletions

View File

@ -337,13 +337,12 @@ void I830InitVideo(ScreenPtr screen)
/* Give our adaptor list enough space for the overlay and/or texture video
* adaptors.
*/
newAdaptors =
malloc((num_adaptors + 2) * sizeof(XF86VideoAdaptorPtr *));
if (newAdaptors == NULL)
newAdaptors = realloc(adaptors,
(num_adaptors + 2) * sizeof(XF86VideoAdaptorPtr));
if (newAdaptors == NULL) {
free(adaptors);
return;
memcpy(newAdaptors, adaptors,
num_adaptors * sizeof(XF86VideoAdaptorPtr));
}
adaptors = newAdaptors;
/* Add the adaptors supported by our hardware. First, set up the atoms