mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 11:10:05 +00:00
Notify the context of instructions that are being erased.
Fixes use-after-free error in RemoveDuplicatesPass Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1004
This commit is contained in:
parent
3e08a3f718
commit
0cae89e79e
2
CHANGES
2
CHANGES
@ -2,6 +2,8 @@ Revision history for SPIRV-Tools
|
||||
|
||||
v2017.2-dev 2017-11-23
|
||||
- Start v2017.2-dev
|
||||
- Fixes:
|
||||
#1004: Use after free of an instruction, in remove-duplicates transform
|
||||
|
||||
v2017.1 2017-11-23
|
||||
- Update README with details on the public_spirv_tools_dev@khronos.org mailing list.
|
||||
|
@ -58,6 +58,7 @@ bool RemoveDuplicatesPass::RemoveDuplicateCapabilities(
|
||||
++i;
|
||||
} else {
|
||||
// It's a duplicate, remove it.
|
||||
irContext->KillInst(&*i);
|
||||
i = i.Erase();
|
||||
modified = true;
|
||||
}
|
||||
@ -82,6 +83,7 @@ bool RemoveDuplicatesPass::RemoveDuplicatesExtInstImports(
|
||||
} else {
|
||||
// It's a duplicate, remove it.
|
||||
irContext->ReplaceAllUsesWith(i->result_id(), res.first->second);
|
||||
irContext->KillInst(&*i);
|
||||
i = i.Erase();
|
||||
modified = true;
|
||||
}
|
||||
@ -121,6 +123,7 @@ bool RemoveDuplicatesPass::RemoveDuplicateTypes(ir::IRContext* irContext) const
|
||||
// The same type has already been seen before, remove this one.
|
||||
irContext->ReplaceAllUsesWith(i->result_id(), idToKeep);
|
||||
modified = true;
|
||||
irContext->KillInst(&*i);
|
||||
i = i.Erase();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user