Merge pull request #78 from realm/mar/weakrealmnotifier-leak

Fix a potential leak within WeakRealmNotifier
This commit is contained in:
Mark Rowe 2016-06-01 13:07:56 -07:00
commit 57ee591809
2 changed files with 9 additions and 0 deletions

View File

@ -69,6 +69,8 @@ WeakRealmNotifier::WeakRealmNotifier(WeakRealmNotifier&& rgt)
WeakRealmNotifier& WeakRealmNotifier::operator=(WeakRealmNotifier&& rgt)
{
WeakRealmNotifierBase::operator=(std::move(rgt));
invalidate();
m_runloop = rgt.m_runloop;
m_signal = rgt.m_signal;
rgt.m_runloop = nullptr;
@ -78,6 +80,11 @@ WeakRealmNotifier& WeakRealmNotifier::operator=(WeakRealmNotifier&& rgt)
}
WeakRealmNotifier::~WeakRealmNotifier()
{
invalidate();
}
void WeakRealmNotifier::invalidate()
{
if (m_signal) {
CFRunLoopSourceInvalidate(m_signal);

View File

@ -40,6 +40,8 @@ public:
void notify();
private:
void invalidate();
CFRunLoopRef m_runloop;
CFRunLoopSourceRef m_signal;
};