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

Author: Nicolai Hähnle <nicolai.haeh...@amd.com>
Date:   Fri Mar 23 15:43:58 2018 +0100

glsl: prevent spurious Valgrind errors when serializing NIR

It looks as if the structure fields array is fully initialized below,
but in fact at least gcc in debug builds will not actually overwrite
the unused bits of bit fields.

Reviewed-by: Timothy Arceri <tarc...@itsqueeze.com>

---

 src/compiler/glsl_types.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 11947c917a..d11c365e19 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -105,8 +105,10 @@ glsl_type::glsl_type(const glsl_struct_field *fields, 
unsigned num_fields,
 
    assert(name != NULL);
    this->name = ralloc_strdup(this->mem_ctx, name);
-   this->fields.structure = ralloc_array(this->mem_ctx,
-                                         glsl_struct_field, length);
+   /* Zero-fill to prevent spurious Valgrind errors when serializing NIR
+    * due to uninitialized unused bits in bit fields. */
+   this->fields.structure = rzalloc_array(this->mem_ctx,
+                                          glsl_struct_field, length);
 
    for (i = 0; i < length; i++) {
       this->fields.structure[i] = fields[i];

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to