[Mesa-dev] [PATCH] mesa/prgram: Use nir_variable_create in prog_to_nir to avoid a memleak.

Tapani Pälli tapani.palli at intel.com
Tue Feb 26 09:25:38 UTC 2019


Hi Matthias;

I pushed this change earlier (commit 1d5e5ec30a6) with you in 'Reported-by'.

Thanks;

// Tapani

On 2/25/19 1:16 PM, Matthias Lorenz wrote:
> Use of nir_variable_create was suggested by Jason Ekstrand.
> 
> Fixes: 3d7611e9 "st/nir: use NIR for asm programs"
> ---
>   src/mesa/program/prog_to_nir.c | 13 ++++++-------
>   1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
> index 1c9d0018d55..3f8abb121e7 100644
> --- a/src/mesa/program/prog_to_nir.c
> +++ b/src/mesa/program/prog_to_nir.c
> @@ -1012,13 +1012,12 @@ prog_to_nir(const struct gl_program *prog,
>      s = c->build.shader;
> 
>      if (prog->Parameters->NumParameters > 0) {
> -      c->parameters = rzalloc(s, nir_variable);
> -      c->parameters->type =
> -         glsl_array_type(glsl_vec4_type(), prog->Parameters->NumParameters, 0);
> -      c->parameters->name = strdup(prog->Parameters->Parameters[0].Name);
> -      c->parameters->data.read_only = true;
> -      c->parameters->data.mode = nir_var_uniform;
> -      exec_list_push_tail(&s->uniforms, &c->parameters->node);
> +      c->parameters =
> +         nir_variable_create(s, nir_var_uniform,
> +                             glsl_array_type(glsl_vec4_type(),
> +                                             prog->Parameters->NumParameters,
> +                                             0),
> +                             prog->Parameters->Parameters[0].Name);
>      }
> 
>      setup_registers_and_variables(c);
> --
> 2.20.1
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


More information about the mesa-dev mailing list