Mesa (master): glsl/blob: clear padding bytes

Timothy Arceri tarceri at kemper.freedesktop.org
Thu Mar 9 09:41:15 UTC 2017


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

Author: Grazvydas Ignotas <notasas at gmail.com>
Date:   Fri Mar  3 01:59:57 2017 +0200

glsl/blob: clear padding bytes

Since blob is intended for serializing data, it's not a good idea to
leave padding holes with uninitialized data, which may leak heap
contents and hurt compression if the blob is later compressed, like
done by shader cache. Clear it.

Signed-off-by: Grazvydas Ignotas <notasas at gmail.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/compiler/glsl/blob.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/blob.c b/src/compiler/glsl/blob.c
index dd4341b..14dc690 100644
--- a/src/compiler/glsl/blob.c
+++ b/src/compiler/glsl/blob.c
@@ -70,10 +70,13 @@ align_blob(struct blob *blob, size_t alignment)
 {
    const size_t new_size = ALIGN(blob->size, alignment);
 
-   if (! grow_to_fit (blob, new_size - blob->size))
-      return false;
+   if (blob->size < new_size) {
+      if (!grow_to_fit(blob, new_size - blob->size))
+         return false;
 
-   blob->size = new_size;
+      memset(blob->data + blob->size, 0, new_size - blob->size);
+      blob->size = new_size;
+   }
 
    return true;
 }




More information about the mesa-commit mailing list