diff options
author | Mathias Agopian <mathias@google.com> | 2011-06-09 13:54:54 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-06-09 13:54:54 -0700 |
commit | 880b2df55cdbc7c392e7e4d9c31435b7045aa270 (patch) | |
tree | fbdba05380bfafb33957e38c8bbc5609fc74011c /libs | |
parent | 7b75ee78c81bbc2fa44a0573b8939a8f4e44fbff (diff) | |
parent | 96fcb702d75dcfb36c3ebd8fe420c8b29fa67fb7 (diff) | |
download | frameworks_base-880b2df55cdbc7c392e7e4d9c31435b7045aa270.zip frameworks_base-880b2df55cdbc7c392e7e4d9c31435b7045aa270.tar.gz frameworks_base-880b2df55cdbc7c392e7e4d9c31435b7045aa270.tar.bz2 |
am 96fcb702: am b40e85f9: am 645434fb: Merge "Fix a leak in RefBase" into honeycomb-mr2
* commit '96fcb702d75dcfb36c3ebd8fe420c8b29fa67fb7':
Fix a leak in RefBase
Diffstat (limited to 'libs')
-rw-r--r-- | libs/utils/RefBase.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libs/utils/RefBase.cpp b/libs/utils/RefBase.cpp index dd0052a..58e0811 100644 --- a/libs/utils/RefBase.cpp +++ b/libs/utils/RefBase.cpp @@ -418,18 +418,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 { + } + } 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(); + } } } } @@ -551,8 +553,10 @@ RefBase::RefBase() RefBase::~RefBase() { - if (mRefs->mWeak == 0) { - delete mRefs; + if ((mRefs->mFlags & OBJECT_LIFETIME_WEAK) == OBJECT_LIFETIME_WEAK) { + if (mRefs->mWeak == 0) { + delete mRefs; + } } } |