diff options
author | Mathias Agopian <mathias@google.com> | 2011-06-08 16:05:30 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2011-06-08 16:13:39 -0700 |
commit | 19974eccdbd3e4dbd7e3b2cc401db7806d4a17bc (patch) | |
tree | dfa5e50a63e61346d703feece094a14cc09bd9b9 /libs | |
parent | 66040bbb087b04c4bbac8429f91bbff1029e1440 (diff) | |
download | frameworks_base-19974eccdbd3e4dbd7e3b2cc401db7806d4a17bc.zip frameworks_base-19974eccdbd3e4dbd7e3b2cc401db7806d4a17bc.tar.gz frameworks_base-19974eccdbd3e4dbd7e3b2cc401db7806d4a17bc.tar.bz2 |
Fix a leak in RefBase (DO NOT MERGE)
this bug was introduced recently. it caused RefBase's weakref_impl
structure to be leaked for every RefBase object (about 20 bytes).
Change-Id: Ia9b155fbfa643ef72cfb8129e96260a3b806a78c
Diffstat (limited to 'libs')
-rw-r--r-- | libs/utils/RefBase.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libs/utils/RefBase.cpp b/libs/utils/RefBase.cpp index c68e32a..1c870cf 100644 --- a/libs/utils/RefBase.cpp +++ b/libs/utils/RefBase.cpp @@ -373,18 +373,20 @@ void RefBase::weakref_type::decWeak(const void* id) if (c != 1) return; if ((impl->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) { - if (impl->mStrong == INITIAL_STRONG_VALUE) - if (impl->mBase) + if (impl->mStrong == INITIAL_STRONG_VALUE) { + if (impl->mBase) { impl->mBase->destroy(); - else { -// LOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase); + } + } else { + // LOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase); delete impl; } } else { impl->mBase->onLastWeakRef(id); if ((impl->mFlags&OBJECT_LIFETIME_FOREVER) != OBJECT_LIFETIME_FOREVER) { - if (impl->mBase) + if (impl->mBase) { impl->mBase->destroy(); + } } } } @@ -508,10 +510,10 @@ RefBase::RefBase() RefBase::~RefBase() { -// LOGV("Destroying RefBase %p (refs %p)\n", this, mRefs); - if (mRefs->mWeak == 0) { -// LOGV("Freeing refs %p of old RefBase %p\n", mRefs, this); - delete mRefs; + if ((mRefs->mFlags & OBJECT_LIFETIME_WEAK) == OBJECT_LIFETIME_WEAK) { + if (mRefs->mWeak == 0) { + delete mRefs; + } } } |