diff options
| author | Rusty Wagner <rusty.wagner@gmail.com> | 2016-01-31 02:38:32 -0500 |
|---|---|---|
| committer | Rusty Wagner <rusty.wagner@gmail.com> | 2016-01-31 02:38:32 -0500 |
| commit | a48ce3f4aa1266d5b8619cf320a703ba4f697854 (patch) | |
| tree | b8312cccc35b75b51e0b0e99519460c3e9c2240c /basicblock.cpp | |
| parent | bbb74ee011e2b482e1895a513203c11affbac229 (diff) | |
Refactor API to fix design bug that causes use-after-free on many plugin objects
Diffstat (limited to 'basicblock.cpp')
| -rw-r--r-- | basicblock.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/basicblock.cpp b/basicblock.cpp index e27cdfa2..1c86a93b 100644 --- a/basicblock.cpp +++ b/basicblock.cpp @@ -4,51 +4,46 @@ using namespace BinaryNinja; using namespace std; -BasicBlock::BasicBlock(BNBasicBlock* block): m_block(block) +BasicBlock::BasicBlock(BNBasicBlock* block) { -} - - -BasicBlock::~BasicBlock() -{ - BNFreeBasicBlock(m_block); + m_object = block; } Ref<Function> BasicBlock::GetFunction() const { - return new Function(BNGetBasicBlockFunction(m_block)); + return new Function(BNGetBasicBlockFunction(m_object)); } Ref<Architecture> BasicBlock::GetArchitecture() const { - return new CoreArchitecture(BNGetBasicBlockArchitecture(m_block)); + return new CoreArchitecture(BNGetBasicBlockArchitecture(m_object)); } uint64_t BasicBlock::GetStart() const { - return BNGetBasicBlockStart(m_block); + return BNGetBasicBlockStart(m_object); } uint64_t BasicBlock::GetEnd() const { - return BNGetBasicBlockEnd(m_block); + return BNGetBasicBlockEnd(m_object); } uint64_t BasicBlock::GetLength() const { - return BNGetBasicBlockLength(m_block); + return BNGetBasicBlockLength(m_object); } vector<BasicBlockEdge> BasicBlock::GetOutgoingEdges() const { size_t count; - BNBasicBlockEdge* array = BNGetBasicBlockOutgoingEdges(m_block, &count); + BNBasicBlockEdge* array = BNGetBasicBlockOutgoingEdges(m_object, &count); vector<BasicBlockEdge> result; for (size_t i = 0; i < count; i++) @@ -67,11 +62,11 @@ vector<BasicBlockEdge> BasicBlock::GetOutgoingEdges() const bool BasicBlock::HasUndeterminedOutgoingEdges() const { - return BNBasicBlockHasUndeterminedOutgoingEdges(m_block); + return BNBasicBlockHasUndeterminedOutgoingEdges(m_object); } void BasicBlock::MarkRecentUse() { - BNMarkBasicBlockAsRecentlyUsed(m_block); + BNMarkBasicBlockAsRecentlyUsed(m_object); } |
