Typically happen when we want to copy an unnamed shader parameter in the
shader cache.

Note: it is safer to copy an empty string so we can read it back safely.

Fix piglit crashes of the 'texturegatheroffsets' tests

Signed-off-by: Gregory Hainaut <gregory.hain...@gmail.com>
---
 src/compiler/glsl/blob.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/blob.c b/src/compiler/glsl/blob.c
index 769ebf1..f84d7f3 100644
--- a/src/compiler/glsl/blob.c
+++ b/src/compiler/glsl/blob.c
@@ -176,7 +176,10 @@ blob_write_intptr(struct blob *blob, intptr_t value)
 bool
 blob_write_string(struct blob *blob, const char *str)
 {
-   return blob_write_bytes(blob, str, strlen(str) + 1);
+   if (str == NULL)
+      return blob_write_bytes(blob, "", 1);
+   else
+      return blob_write_bytes(blob, str, strlen(str) + 1);
 }
 
 void
-- 
2.1.4

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

Reply via email to