Mesa (master): glsl: don' t leak memory when trying to count loop iterations

Timothy Arceri tarceri at kemper.freedesktop.org
Sat Mar 18 03:12:50 UTC 2017


Module: Mesa
Branch: master
Commit: 40bc1afc9437433f2f1d1c0a6980376ff5670638
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=40bc1afc9437433f2f1d1c0a6980376ff5670638

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Fri Mar 17 21:53:35 2017 +1100

glsl: don't leak memory when trying to count loop iterations

Suggested-by: Damian Dixon <damian.dixon at gmail.com>
Reviewed-by: Elie Tournier <elie.tournier at collabora.com>
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 c717605ec7..fa739afa24 100644
--- a/src/compiler/glsl/loop_controls.cpp
+++ b/src/compiler/glsl/loop_controls.cpp
@@ -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()




More information about the mesa-commit mailing list