shader-types: Check the size of the values
authorRichard Hughes <richard@hughsie.com>
Wed, 16 Jun 2010 15:19:48 +0000 (16:19 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 16 Jun 2010 16:14:57 +0000 (17:14 +0100)
Emit a critical error if the user tries to send more data than
the static shader GValues can hold.

This fixes the random memory corruption you get when specifying
size > 4.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
clutter/clutter-shader-types.c

index 2c35cb8..9ed3998 100644 (file)
@@ -399,6 +399,7 @@ clutter_value_set_shader_float (GValue         *value,
   gint i;
 
   g_return_if_fail (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (value));
+  g_return_if_fail (size <= 4);
 
   shader_float = value->data[0].v_pointer;
 
@@ -428,6 +429,7 @@ clutter_value_set_shader_int (GValue     *value,
   gint i;
 
   g_return_if_fail (CLUTTER_VALUE_HOLDS_SHADER_INT (value));
+  g_return_if_fail (size <= 4);
 
   shader_int = value->data[0].v_pointer;
 
@@ -457,6 +459,7 @@ clutter_value_set_shader_matrix (GValue       *value,
   gint i;
 
   g_return_if_fail (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (value));
+  g_return_if_fail (size <= 4);
 
   shader_matrix = value->data[0].v_pointer;