[Mesa-dev] [PATCH 3/3] glsl/ir_reader: Make sure constants have the right number of components.

Kenneth Graunke kenneth at whitecape.org
Mon Sep 5 12:24:50 PDT 2011


The list of numbers in (constant type (<numbers>)) needs to contain
exactly type->components() numbers (16 for a mat4, 3 for a vec3, etc.)

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/glsl/ir_reader.cpp |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp
index 22009ee..10bf72a 100644
--- a/src/glsl/ir_reader.cpp
+++ b/src/glsl/ir_reader.cpp
@@ -820,6 +820,11 @@ ir_reader::read_constant(s_expression *expr)
       }
       ++k;
    }
+   if (k != type->components()) {
+      ir_read_error(values, "expected %d constant values, found %d",
+		    type->components(), k);
+      return NULL;
+   }
 
    return new(mem_ctx) ir_constant(type, &data);
 }
-- 
1.7.6.1



More information about the mesa-dev mailing list