Mesa (master): radv: don't pass null to _mesa_sha1_update

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 20 11:09:52 UTC 2020


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

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Wed Aug  5 21:03:22 2020 +0100

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 <pendingchaos02 at gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6206>

---

 src/amd/vulkan/radv_pipeline_cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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);



More information about the mesa-commit mailing list