From 18294844584f1a64454593c056148201c4d79ef7 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Tue, 15 Nov 2011 00:38:15 +0100 Subject: nv50/ir: Fix memory corruption in Function::orderInstructions(). "iter" doesn't reference a BasicBlock directly, but a Node::Graph, i.e. BasicBlock::get() is casting to the wrong pointer type. --- src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/gallium/drivers/nv50/codegen') diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp index aafc7cb1a8c..c1c82788756 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp @@ -323,10 +323,14 @@ unsigned int Function::orderInstructions(ArrayList &result) { Iterator *iter; - for (iter = cfg.iteratorCFG(); !iter->end(); iter->next()) - for (Instruction *insn = BasicBlock::get(*iter)->getFirst(); - insn; insn = insn->next) + for (iter = cfg.iteratorCFG(); !iter->end(); iter->next()) { + BasicBlock *bb = + BasicBlock::get(reinterpret_cast(iter->get())); + + for (Instruction *insn = bb->getFirst(); insn; insn = insn->next) result.insert(insn, insn->serial); + } + cfg.putIterator(iter); return result.getSize(); } -- cgit v1.2.3