diff options
| author | 2011-06-08 19:30:47 -0700 | |
|---|---|---|
| committer | 2011-06-08 19:30:47 -0700 | |
| commit | 58d6631e4d2f94cb4ab0f1680536abe849ccfeed (patch) | |
| tree | 628023f8216fd6590f9c0beb3cc0aaef576313ca | |
| parent | 58ac3ee60295512fd7e3a6f7d1df6ce353ee1e7f (diff) | |
| parent | ee8e9af975c2ee55cae02cf3a5655ec6692fd5f5 (diff) | |
am 645434fb: Merge "Fix a leak in RefBase" into honeycomb-mr2
* commit '645434fb4eff408698423d70904fb8fc709a5225':
Fix a leak in RefBase
| -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 7de263326a..ae55a6143b 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; + } } } |