From c17d0cc488320a2cc5c67e7db7c07e7869cc0b36 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 4 Jan 2023 10:22:57 -0500 Subject: [PATCH] lavapipe: use PACKAGE_VERSION for cache uuid in release builds MESA_GIT_SHA1 is defined as "", which results in invalid access fixes #7673 Fixes: b38879f8c5f ("vallium: initial import of the vulkan frontend") Reviewed-by: Dave Airlie Part-of: --- src/gallium/frontends/lavapipe/lvp_device.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index 1de670987d8..eff8aebc7aa 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -889,8 +889,13 @@ lvp_enumerate_physical_devices(struct vk_instance *vk_instance) void lvp_device_get_cache_uuid(void *uuid) { - memset(uuid, 0, VK_UUID_SIZE); - snprintf(uuid, VK_UUID_SIZE, "val-%s", &MESA_GIT_SHA1[4]); + memset(uuid, 'a', VK_UUID_SIZE); + if (MESA_GIT_SHA1[0]) + /* debug build */ + memcpy(uuid, &MESA_GIT_SHA1[4], strlen(MESA_GIT_SHA1) - 4); + else + /* release build */ + memcpy(uuid, PACKAGE_VERSION, strlen(PACKAGE_VERSION)); } VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,