From 9a6a48f8921f3e2c56302c751960b19073a03f3b Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 18 Jan 2022 21:33:02 -0500 Subject: Fix leak in reference count assignment operator --- binaryninjaapi.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 9cd6475a..e16158cc 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -253,20 +253,18 @@ namespace BinaryNinja Ref& operator=(Ref&& other) { - if (this != &other) + if (m_obj) { - if (!m_obj) - m_obj = other.m_obj; - else if (m_obj != other.m_obj) - { - m_obj->Release(); - m_obj = other.m_obj; - } - other.m_obj = 0; #ifdef BN_REF_COUNT_DEBUG - m_assignmentTrace = other.m_assignmentTrace; + BNUnregisterObjectRefDebugTrace(typeid(T).name(), m_assignmentTrace); #endif + m_obj->Release(); } + m_obj = other.m_obj; + other.m_obj = 0; +#ifdef BN_REF_COUNT_DEBUG + m_assignmentTrace = other.m_assignmentTrace; +#endif return *this; } -- cgit v1.3.1