[Mesa-dev] [PATCH] glsl: don't leak memory when trying to count loop iterations
tournier.elie
tournier.elie at gmail.com
Fri Mar 17 11:22:28 UTC 2017
You can probably add a "Suggested-by" in the message.
Reviewed-by: Elie Tournier <elie.tournier at collabora.com>
On 17 March 2017 at 10:53, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99789
> ---
> src/compiler/glsl/loop_controls.cpp | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/glsl/loop_controls.cpp b/src/compiler/glsl/loop_controls.cpp
> index c717605..fa739af 100644
> --- a/src/compiler/glsl/loop_controls.cpp
> +++ b/src/compiler/glsl/loop_controls.cpp
> @@ -90,23 +90,24 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
>
> void *mem_ctx = ralloc_context(NULL);
>
> ir_expression *const sub =
> new(mem_ctx) ir_expression(ir_binop_sub, from->type, to, from);
>
> ir_expression *const div =
> new(mem_ctx) ir_expression(ir_binop_div, sub->type, sub, increment);
>
> ir_constant *iter = div->constant_expression_value();
> -
> - if (iter == NULL)
> + if (iter == NULL) {
> + ralloc_free(mem_ctx);
> return -1;
> + }
>
> if (!iter->type->is_integer()) {
> const ir_expression_operation op = iter->type->is_double()
> ? ir_unop_d2i : ir_unop_f2i;
> ir_rvalue *cast =
> new(mem_ctx) ir_expression(op, glsl_type::int_type, iter, NULL);
>
> iter = cast->constant_expression_value();
> }
>
> --
> 2.9.3
>
> _______________________________________________
> 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