[Mesa-stable] [Mesa-dev] [PATCH] glx: Properly handle cases where screen creation fails
Chuck Atkins
chuck.atkins at kitware.com
Wed Feb 21 14:48:54 UTC 2018
> > - if (xmdpy->smapi->destroy)
> > - xmdpy->smapi->destroy(xmdpy->smapi);
> > - free(xmdpy->smapi);
> > + if (xmdpy->smapi)
> > + {
> > + if (xmdpy->smapi->destroy)
> > + xmdpy->smapi->destroy(xmdpy->smapi);
> > + free(xmdpy->smapi);
> > + }
>
> I don't know this code so I don't know if the patch is right, but just
> pointing out this hunk could be written as a simple one-line change:
>
> - if (xmdpy->smapi->destroy)
> + if (xmdpy->smapi && xmdpy->smapi->destroy)
>
Combining the two would cause xmdpy->smapi to leak when the
xmdpy->smapi->destroy callback is null. This way, destroy get's called
when it's set but xmdpy->smapi always gets freed.
- Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-stable/attachments/20180221/98f0bebd/attachment-0001.html>
More information about the mesa-stable
mailing list