From: Piers Daniell Date: Fri, 3 Jun 2022 18:21:00 +0000 (-0600) Subject: Fix regression from CL-9387 to handle empty cache properly X-Git-Tag: upstream/1.3.5~292 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0fa23840d35ec07ac182be6effe8d3eff5cb2d9f;p=platform%2Fupstream%2FVK-GL-CTS.git Fix regression from CL-9387 to handle empty cache properly The new program cache code from CL-9387 didn't handle the case where cacheSearch() is called with an empty cache. It would look at the first node key regardless, which is uninitialized data, and attempt to follow the left/right node pointers, which were also uninitialized. This could result in crash or worse. This CL simply checks if the cache is empty, and if so doesn't attempt to read the invalid first node. Affects: * (all tests with shaders) VK-GL-CTS issue: 3565 Components: Vulkan, Framework Change-Id: Ia813d8caf3170b0c1995bdc43a5f345b578ab615 --- diff --git a/external/vulkancts/framework/vulkan/vkPrograms.cpp b/external/vulkancts/framework/vulkan/vkPrograms.cpp index 2b06e79..1653ded 100644 --- a/external/vulkancts/framework/vulkan/vkPrograms.cpp +++ b/external/vulkancts/framework/vulkan/vkPrograms.cpp @@ -234,8 +234,14 @@ struct cacheNode cacheNode* cacheSearch (deUint32 key) { - cacheNode* r = (cacheNode*)(cacheMempool + 1); - unsigned int p = 0; + cacheNode* r = (cacheNode*)(cacheMempool + 1); + int* tail = (int*)cacheMempool; + unsigned int p = 0; + + if (!*tail) { + // Cache is empty. + return 0; + } while (1) {