From: Rhys Perry Date: Wed, 5 Aug 2020 20:03:22 +0000 (+0100) Subject: radv: don't pass null to _mesa_sha1_update X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4f08af6766c23295922a08a95d0183820f7bc702;p=mesa.git radv: don't pass null to _mesa_sha1_update This could then pass NULL to memcpy. Fixes UBSan error: ../src/util/sha1/sha1.c:140:8: runtime error: null pointer passed as argument 2, which is declared to never be null Signed-off-by: Rhys Perry Reviewed-by: Samuel Pitoiset Part-of: --- diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c index 8cbf312019c..fe38f301009 100644 --- a/src/amd/vulkan/radv_pipeline_cache.c +++ b/src/amd/vulkan/radv_pipeline_cache.c @@ -133,7 +133,7 @@ radv_hash_shaders(unsigned char *hash, _mesa_sha1_update(&ctx, module->sha1, sizeof(module->sha1)); _mesa_sha1_update(&ctx, stages[i]->pName, strlen(stages[i]->pName)); - if (spec_info) { + if (spec_info && spec_info->mapEntryCount) { _mesa_sha1_update(&ctx, spec_info->pMapEntries, spec_info->mapEntryCount * sizeof spec_info->pMapEntries[0]); _mesa_sha1_update(&ctx, spec_info->pData, spec_info->dataSize);