summaryrefslogtreecommitdiff
path: root/binaryninjaapi.h
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2022-01-18 21:33:02 -0500
committerRusty Wagner <rusty.wagner@gmail.com>2022-01-18 21:33:02 -0500
commit9a6a48f8921f3e2c56302c751960b19073a03f3b (patch)
tree106a5c8e72d358ebf7b162a74055e356f6343909 /binaryninjaapi.h
parente88ed98d60b046cbeb5f4c96fc374c7576d7b57a (diff)
Fix leak in reference count assignment operator
Diffstat (limited to 'binaryninjaapi.h')
-rw-r--r--binaryninjaapi.h18
1 files changed, 8 insertions, 10 deletions
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<T>& operator=(Ref<T>&& 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;
}