diff options
| author | Rusty Wagner <rusty.wagner@gmail.com> | 2022-01-18 21:33:02 -0500 |
|---|---|---|
| committer | Rusty Wagner <rusty.wagner@gmail.com> | 2022-01-18 21:33:02 -0500 |
| commit | 9a6a48f8921f3e2c56302c751960b19073a03f3b (patch) | |
| tree | 106a5c8e72d358ebf7b162a74055e356f6343909 /binaryninjaapi.h | |
| parent | e88ed98d60b046cbeb5f4c96fc374c7576d7b57a (diff) | |
Fix leak in reference count assignment operator
Diffstat (limited to 'binaryninjaapi.h')
| -rw-r--r-- | binaryninjaapi.h | 18 |
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; } |
