There is a slim chance that function shadercacheLoad() can pass a null
pointer into the std::string constructor, causing an exception. This can
happen in the case there is a mismatch between the calculated hash and
the one stored in the cache file.
This commit makes the code more robust, handling this case as a miss.
Components: Vulkan
VK-GL-CTS issue: 2052
Change-Id: I84a382dec51f487314304ec9057cefdff22920c3
deUint8* bin = 0;
char* source = 0;
deBool ok = true;
- deBool diff;
+ deBool diff = true;
cacheFileMutex.lock();
if (cacheFileIndex.count(hash) == 0)
source = new char[sourcelength + 1];
ok = fread(source, 1, sourcelength, file) == (size_t)sourcelength;
source[sourcelength] = 0;
+ diff = shaderstring != std::string(source);
}
- diff = shaderstring != std::string(source);
if (!ok || diff)
{
// Mismatch, but may still exist in cache if there were hash collisions