glsl: don't leak memory when trying to count loop iterations
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 17 Mar 2017 10:53:35 +0000 (21:53 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Sat, 18 Mar 2017 03:12:40 +0000 (14:12 +1100)
Suggested-by: Damian Dixon <damian.dixon@gmail.com>
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99789

src/compiler/glsl/loop_controls.cpp

index c717605ec743e02ef8e34c845d38e28c749ef613..fa739afa24ef9aa9387acd0c1242f8567c1c7537 100644 (file)
@@ -97,9 +97,10 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
       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()