linker: Fix off-by-one error implicit array sizing
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 16 Feb 2011 02:17:53 +0000 (18:17 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 16 Feb 2011 02:22:33 +0000 (18:22 -0800)
Arrays are zero based.  If the highest element accessed is 6, the
array needs to have 7 elements.

Fixes piglit test glsl-fs-implicit-array-size-03 and bugzilla #34198.

NOTE: This is a candidate for the 7.9 and 7.10 branches.

src/glsl/linker.cpp

index 46cd1950c86b42ccc21d23627462c14296be5e19..6c003bb025672b5bbdb1ad89b8f468199ae6bc43 100644 (file)
@@ -926,7 +926,7 @@ link_intrastage_shaders(void *mem_ctx,
            if (var->type->is_array() && (var->type->length == 0)) {
               const glsl_type *type =
                  glsl_type::get_array_instance(var->type->fields.array,
-                                               var->max_array_access);
+                                               var->max_array_access + 1);
 
               assert(type != NULL);
               var->type = type;