glsl: explicitly zero out padding to gl_shader_variable bitfield
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sat, 24 Jun 2017 08:27:18 +0000 (10:27 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 5 Jul 2017 10:25:49 +0000 (12:25 +0200)
Otherwise, the padding bits remain undefined, which leads to valgrind
errors when storing the gl_shader_variable in the disk cache.

v2: use rzalloc instead of an explicit padding member variable

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/glsl/linker.cpp

index 6ddf0cbb0cedf83790b858eb08fe147cec3ef6ea..b4784c51199e3bb92913f11631036f945b356922 100644 (file)
@@ -3732,7 +3732,10 @@ create_shader_variable(struct gl_shader_program *shProg,
                        bool use_implicit_location, int location,
                        const glsl_type *outermost_struct_type)
 {
-   gl_shader_variable *out = ralloc(shProg, struct gl_shader_variable);
+   /* Allocate zero-initialized memory to ensure that bitfield padding
+    * is zero.
+    */
+   gl_shader_variable *out = rzalloc(shProg, struct gl_shader_variable);
    if (!out)
       return NULL;