mesa: In emit_texenv() type mismatch was forced with typecast
authorJuha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Mon, 24 Feb 2014 07:42:17 +0000 (09:42 +0200)
committerTapani Pälli <tapani.palli@intel.com>
Wed, 18 Jun 2014 13:15:51 +0000 (16:15 +0300)
Type mismatch caused random memory to be copied when casted
memory area was smaller than expected type.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/ff_fragment_shader.cpp

index 8c360970f87b6ee6d4ca26cfebcd918900669818..211583738c8bb69e3c0026a0db907a2f11eb092c 100644 (file)
@@ -877,14 +877,15 @@ emit_texenv(texenv_fragment_program *p, GLuint unit)
         shift = new(p->mem_ctx) ir_constant((float)(1 << rgb_shift));
       }
       else {
-        float const_data[4] = {
-           float(1 << rgb_shift),
-           float(1 << rgb_shift),
-           float(1 << rgb_shift),
-           float(1 << alpha_shift)
-        };
-        shift = new(p->mem_ctx) ir_constant(glsl_type::vec4_type,
-                                            (ir_constant_data *)const_data);
+         ir_constant_data const_data;
+
+         const_data.f[0] = float(1 << rgb_shift);
+         const_data.f[1] = float(1 << rgb_shift);
+         const_data.f[2] = float(1 << rgb_shift);
+         const_data.f[3] = float(1 << alpha_shift);
+
+         shift = new(p->mem_ctx) ir_constant(glsl_type::vec4_type,
+                                             &const_data);
       }
 
       return saturate(mul(deref, shift));