Throw if word count of SPIR-V instruction is 0.

Avoids infinite loop on garbage SPIR-V files.
This commit is contained in:
Hans-Kristian Arntzen 2016-07-08 10:47:03 +02:00
parent cc3aba52ba
commit 416566bab6

View File

@ -30,6 +30,10 @@ Instruction::Instruction(const vector<uint32_t> &spirv, uint32_t &index)
{
op = spirv[index] & 0xffff;
count = (spirv[index] >> 16) & 0xffff;
if (count == 0)
throw CompilerError("SPIR-V instructions cannot consume 0 words. Invalid SPIR-V file.");
offset = index + 1;
length = count - 1;