[Mesa-dev] [PATCH 1/2] llvmpipe: move lp_jit_screen_init() call after allocation of screen object

Michel Dänzer michel at daenzer.net
Mon Sep 29 18:45:17 PDT 2014


On 30.09.2014 07:16, Brian Paul wrote:
> The screen argument isn't actually used by lp_jit_screen_init() at this
> time,

I guess that's why gcc didn't warn about it?


> but let's move the call so that we pass a valid pointer.
> ---
>   src/gallium/drivers/llvmpipe/lp_screen.c |    6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
> index 3025322..e3c3980 100644
> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
> @@ -557,9 +557,6 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
>          return NULL;
>   #endif
>
> -   if (!lp_jit_screen_init(screen))
> -      return NULL;
> -
>   #ifdef DEBUG
>      LP_DEBUG = debug_get_flags_option("LP_DEBUG", lp_debug_flags, 0 );
>   #endif
> @@ -570,6 +567,9 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
>      if (!screen)
>         return NULL;
>
> +   if (!lp_jit_screen_init(screen))
> +      return NULL;
> +

This leaks screen in the failure case.


-- 
Earthling Michel Dänzer            |                  http://www.amd.com
Libre software enthusiast          |                Mesa and X developer


More information about the mesa-dev mailing list