[Mesa-dev] [PATCH 1/3] glx: Fix leaks in DRI2 screen creation error paths.

Henri Verbeet hverbeet at gmail.com
Mon Jan 31 08:52:40 PST 2011


On 31 January 2011 17:43, Julien Cristau <jcristau at debian.org> wrote:
> On Sun, Jan 30, 2011 at 00:00:48 +0100, Henri Verbeet wrote:
>
>> @@ -918,12 +921,15 @@ dri2CreateScreen(int screen, struct glx_display * priv)
>>     return &psc->base;
>>
>>  handle_error:
>> +   if (psc->fd)
>> +      close(psc->fd);
>
> 0 is a valid fd.  It might be better to initialize fd to -1 and check
> for >= 0 here.
>
Yes, but isn't 0 defined to be stdin on any platform we care about?
Though another reason to initialize to -1 would be that I just noticed
we'd technically be passing an invalid fd to close() if the open
failed.


More information about the mesa-dev mailing list