[Mesa-dev] [PATCH] glsl: Fix memory leak in builtin_builder::_image_prototype.
Ilia Mirkin
imirkin at alum.mit.edu
Wed Oct 1 22:18:32 PDT 2014
On Wed, Oct 1, 2014 at 6:12 AM, Iago Toral Quiroga <itoral at igalia.com> wrote:
> in_var calls the ir_variable constructor, which dups the variable name.
I just came across this too, and tested that your patch fixed it.
There has to be some better way of dealing with this, like making a
fixed-size char buffer on the stack and snprintf'ing to it, but...
this is done once per program, so it's hard to bring myself to care.
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> src/glsl/builtin_functions.cpp | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
> index 5a024cb..7d61fcc 100644
> --- a/src/glsl/builtin_functions.cpp
> +++ b/src/glsl/builtin_functions.cpp
> @@ -4465,9 +4465,11 @@ builtin_builder::_image_prototype(const glsl_type *image_type,
> sig->parameters.push_tail(in_var(glsl_type::int_type, "sample"));
>
> /* Data arguments. */
> - for (unsigned i = 0; i < num_arguments; ++i)
> - sig->parameters.push_tail(in_var(data_type,
> - ralloc_asprintf(NULL, "arg%d", i)));
> + for (unsigned i = 0; i < num_arguments; ++i) {
> + char *arg_name = ralloc_asprintf(NULL, "arg%d", i);
> + sig->parameters.push_tail(in_var(data_type, arg_name));
> + ralloc_free(arg_name);
> + }
>
> /* Set the maximal set of qualifiers allowed for this image
> * built-in. Function calls with arguments having fewer
> --
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list