From f6f7e517e577a67f01256ca0b0edea83729849f4 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Sat, 10 Jan 2015 17:43:04 +0100 Subject: [PATCH] Fix layout if functions include blocks before entry If a function contained a block with a lower address than it's entry a integer overflow occured resulting in bad layout. Handled now correctly. --- src/gui/Mainwindow.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gui/Mainwindow.cxx b/src/gui/Mainwindow.cxx index 5643beb..196db38 100644 --- a/src/gui/Mainwindow.cxx +++ b/src/gui/Mainwindow.cxx @@ -88,8 +88,14 @@ void Mainwindow::addFunction(Function* fun) { Disassembler * dis = manager->getDisassembler(); BasicBlock * block = dis->getBasicBlock(fun->getStartAddress()); + uint64_t start_address(std::numeric_limits::max()); + for (auto b : fun->blocks()) { + if (b.first < start_address) + start_address = b.first; + } + local__add_basic_block(block, manager->getDisassembler(), blocks, scene, - block->getStartAddress(), 100); + start_address, 100); QGraphicsView * view = new QGraphicsView(scene); w->addTab(view, "CFG"); -- 2.39.2