diff options
| author | Brandon Miller <brandon@vector35.com> | 2025-03-21 13:13:11 -0400 |
|---|---|---|
| committer | Brandon Miller <brandon@vector35.com> | 2025-03-21 13:14:00 -0400 |
| commit | 7f12fa7de71fb13bcb7e989f08f36e4d8edfb043 (patch) | |
| tree | a521443a50aab5d831b03c9edcbc1898ff54ce87 /examples/triage | |
| parent | b792810d127f2b9a1d681a2c22c2ba110ecb42f8 (diff) | |
Fix memory leak in base address detection
Diffstat (limited to 'examples/triage')
| -rw-r--r-- | examples/triage/baseaddress.cpp | 16 | ||||
| -rw-r--r-- | examples/triage/baseaddress.h | 14 |
2 files changed, 21 insertions, 9 deletions
diff --git a/examples/triage/baseaddress.cpp b/examples/triage/baseaddress.cpp index cb8f5176..436066eb 100644 --- a/examples/triage/baseaddress.cpp +++ b/examples/triage/baseaddress.cpp @@ -29,6 +29,22 @@ string BaseAddressDetectionConfidenceToString(BNBaseAddressDetectionConfidence l } +BaseAddressDetectionThread::BaseAddressDetectionThread(BaseAddressDetectionQtInputs* widgetInputs, + BinaryNinja::Ref<BinaryNinja::BinaryView> bv) +{ + m_inputs = widgetInputs; + m_view = bv; + m_baseDetection = new BinaryNinja::BaseAddressDetection(m_view); +} + + +BaseAddressDetectionThread::~BaseAddressDetectionThread() +{ + if (m_baseDetection) + delete m_baseDetection; +} + + void BaseAddressDetectionThread::run() { BaseAddressDetectionQtResults results; diff --git a/examples/triage/baseaddress.h b/examples/triage/baseaddress.h index ba512ff1..dd7ead32 100644 --- a/examples/triage/baseaddress.h +++ b/examples/triage/baseaddress.h @@ -40,18 +40,14 @@ class BaseAddressDetectionThread : public QThread { Q_OBJECT BinaryNinja::Ref<BinaryNinja::BinaryView> m_view; - BinaryNinja::BaseAddressDetection* m_baseDetection; + BinaryNinja::BaseAddressDetection* m_baseDetection = nullptr; BaseAddressDetectionQtInputs* m_inputs {}; void run() override; public: - BaseAddressDetectionThread(BaseAddressDetectionQtInputs* widgetInputs, BinaryNinja::Ref<BinaryNinja::BinaryView> bv) - { - m_inputs = widgetInputs; - m_view = bv; - m_baseDetection = new BinaryNinja::BaseAddressDetection(m_view); - } - + BaseAddressDetectionThread(BaseAddressDetectionQtInputs* widgetInputs, + BinaryNinja::Ref<BinaryNinja::BinaryView> bv); + ~BaseAddressDetectionThread(); void Abort() { m_baseDetection->Abort(); } bool IsAborted() { return m_baseDetection->IsAborted(); } @@ -89,4 +85,4 @@ class BaseAddressDetectionWidget : public QWidget public: BaseAddressDetectionWidget(QWidget* parent, BinaryNinja::Ref<BinaryNinja::BinaryView> bv); -};
\ No newline at end of file +}; |
