[Mesa-dev] [PATCH 1/1] glsl/blob: handle copy of NULL ptr in blob_write_string
Gregory Hainaut
gregory.hainaut at gmail.com
Thu Mar 30 19:55:27 UTC 2017
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.hainaut at 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
More information about the mesa-dev
mailing list