diff options
author | Mathias Agopian <mathias@google.com> | 2011-06-08 19:56:06 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-06-08 19:56:06 -0700 |
commit | 17574b9a0a7cc1cf215935fce2474ca30d387046 (patch) | |
tree | f516abc203a931e356f8e639de054d98cbfa880e /libs/utils | |
parent | 0315a2c5640dc91cd1689db9dff997e43e4effca (diff) | |
parent | 19974eccdbd3e4dbd7e3b2cc401db7806d4a17bc (diff) | |
download | frameworks_base-17574b9a0a7cc1cf215935fce2474ca30d387046.zip frameworks_base-17574b9a0a7cc1cf215935fce2474ca30d387046.tar.gz frameworks_base-17574b9a0a7cc1cf215935fce2474ca30d387046.tar.bz2 |
am 19974ecc: Fix a leak in RefBase (DO NOT MERGE)
* commit '19974eccdbd3e4dbd7e3b2cc401db7806d4a17bc':
Fix a leak in RefBase (DO NOT MERGE)
Diffstat (limited to 'libs/utils')
-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 3c560ae..2e81615 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; + } } } |