mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2025-01-11 17:10:06 +00:00
Avoid uninitialized access to instruction opcode (#4673)
Ensures that instruction's opcode is set to something default when parsing the module with --preserve-numeric-ids enabled. This avoids uninitialized accesses and knock-on buffer overflows. Fixes #4672.
This commit is contained in:
parent
df2aad68b9
commit
75e53b9f68
@ -715,6 +715,12 @@ spv_result_t GetNumericIds(const spvtools::AssemblyGrammar& grammar,
|
||||
while (context.hasText()) {
|
||||
spv_instruction_t inst;
|
||||
|
||||
// Operand parsing sometimes involves knowing the opcode of the instruction
|
||||
// being parsed. A malformed input might feature such an operand *before*
|
||||
// the opcode is known. To guard against accessing an uninitialized opcode,
|
||||
// the instruction's opcode is initialized to a default value.
|
||||
inst.opcode = SpvOpMax;
|
||||
|
||||
if (spvTextEncodeOpcode(grammar, &context, &inst)) {
|
||||
return SPV_ERROR_INVALID_TEXT;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user