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

Author: Kenneth Graunke <kenn...@whitecape.org>
Date:   Fri Aug 20 02:04:52 2010 -0700

ast_to_hir: Fix crash when a function shadows a variable.

The code would attempt to add a new signature to the ir_function, which
didn't exist.  Simply bailing out/returning early seems reasonable.

Fixes piglit test redeclaration-02.vert, and fixes a crash in
redeclaration-03.vert (the test still fails).

---

 src/glsl/ast_to_hir.cpp |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index bd1ab78..0d2c471 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2149,7 +2149,6 @@ ast_function::hir(exec_list *instructions,
            YYLTYPE loc = this->get_location();
 
            _mesa_glsl_error(& loc, state, "function `%s' redefined", name);
-           sig = NULL;
         }
       }
    } else if (state->symbols->name_declared_this_scope(name)) {
@@ -2159,7 +2158,7 @@ ast_function::hir(exec_list *instructions,
 
       _mesa_glsl_error(& loc, state, "function name `%s' conflicts with "
                       "non-function", name);
-      sig = NULL;
+      return NULL;
    } else {
       f = new(ctx) ir_function(name);
       state->symbols->add_function(f->name, f);
@@ -2207,6 +2206,8 @@ ast_function_definition::hir(exec_list *instructions,
    prototype->hir(instructions, state);
 
    ir_function_signature *signature = prototype->signature;
+   if (signature == NULL)
+      return NULL;
 
    assert(state->current_function == NULL);
    state->current_function = signature;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to