Mesa (master): glsl: explicitly zero out padding to gl_shader_variable bitfield

Nicolai Hähnle nh at kemper.freedesktop.org
Wed Jul 5 10:32:00 UTC 2017


Module: Mesa
Branch: master
Commit: 210ebd4b9c1b510ff1b29a81aa7512ea77056966
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=210ebd4b9c1b510ff1b29a81aa7512ea77056966

Author: Nicolai Hähnle <nicolai.haehnle at amd.com>
Date:   Sat Jun 24 10:27:18 2017 +0200

glsl: explicitly zero out padding to gl_shader_variable bitfield

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 at amd.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/compiler/glsl/linker.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 6ddf0cbb0c..b4784c5119 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -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;
 




More information about the mesa-commit mailing list