blob: Don't valgrind assert for defined memory if we aren't writing.
authorEmma Anholt <emma@anholt.net>
Thu, 20 Apr 2023 21:57:41 +0000 (14:57 -0700)
committerMarge Bot <emma+marge@anholt.net>
Mon, 24 Apr 2023 20:48:33 +0000 (20:48 +0000)
commitae2784b83232548d62eb488e82a3a4315de50300
tree5b7c92b44dd823eaa634d587655a6225bb65fbb2
parentc060b649c5a866f42e5df73f41c6e2809cf30e99
blob: Don't valgrind assert for defined memory if we aren't writing.

The VK pipeline cache passes a NULL bytes with a nonzero size to a
NULL-data blob to set up the size of the blob.  In this case, we don't
actually execute the memcpy, so the non-existent "bytes" doesn't need to
have defined contents.  Avoids a valgrind warning:

==972858== Unaddressable byte(s) found during client check request
==972858==    at 0x147F4166: blob_write_bytes (blob.c:165)
==972858==    by 0x147F4166: blob_write_bytes (blob.c:158)
==972858==    by 0x14695FFF: vk_pipeline_cache_object_serialize (vk_pipeline_cache.c:240)
[...]
==972858==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

Fixes: 591da9877900 ("vulkan: Add a common VkPipelineCache implementation")
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22617>
src/util/blob.c