LibJS: Don't mark blocks for unification multiple times

This would cause a UAF otherwise
This commit is contained in:
Hendiadyoin1 2022-11-02 14:28:47 +01:00 committed by Ali Mohammad Pur
parent 35db0c5e18
commit 7697e09660
Notes: sideshowbarker 2024-07-18 00:41:35 +09:00

View File

@ -24,6 +24,8 @@ void UnifySameBlocks::perform(PassPipelineExecutable& executable)
auto& block = executable.executable.basic_blocks[i];
auto block_bytes = block.instruction_stream();
for (auto& candidate_block : executable.executable.basic_blocks.span().slice(i + 1)) {
if (equal_blocks.contains(&*candidate_block))
continue;
// FIXME: This can probably be relaxed a bit...
if (candidate_block->size() != block.size())
continue;