[PATCH 1/5] __glXDRIscreenCreateContext: free context on failure, instead of leaking it

Ian Romanick idr at freedesktop.org
Thu Feb 14 18:22:50 PST 2013


On 02/10/2013 12:39 PM, Alan Coopersmith wrote:
> Reported with other leaks found by cppcheck in bugzilla #50281
> https://bugs.freedesktop.org/show_bug.cgi?id=50281
>
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> ---
>   glx/glxdri.c |    8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/glx/glxdri.c b/glx/glxdri.c
> index da46468..1563e51 100644
> --- a/glx/glxdri.c
> +++ b/glx/glxdri.c
> @@ -645,8 +645,10 @@ __glXDRIscreenCreateContext(__GLXscreen * baseScreen,
>       for (i = 0; i < pScreen->numVisuals; i++, visual++)
>           if (visual->vid == glxConfig->visualID)
>               break;
> -    if (i == pScreen->numVisuals)
> +    if (i == pScreen->numVisuals) {
> +        free(context);
>           return NULL;
> +    }
>
>       context->hwContextID = FakeClientID(0);
>
> @@ -655,8 +657,10 @@ __glXDRIscreenCreateContext(__GLXscreen * baseScreen,
>                                 context->hwContextID, &hwContext);
>       __glXleaveServer(GL_FALSE);
>
> -    if (!retval)
> +    if (!retval) {
> +        free(context);
>           return NULL;
> +    }
>
>       context->driContext = screen->legacy->createNewContext(screen->driScreen, config->driConfig, 0,     /* render type */
>                                                              driShare,
>



More information about the xorg-devel mailing list