diff options
author | Mathias Agopian <mathias@google.com> | 2011-06-08 19:28:39 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-06-08 19:28:39 -0700 |
commit | 645434fb4eff408698423d70904fb8fc709a5225 (patch) | |
tree | 8325e3116ca99ee1bade76afa69f6906b6eaaa73 | |
parent | 4381f6421ca408d1dc66430ddfb107c5011bfe25 (diff) | |
parent | 2c0042b666a969091c931614f2fc0dce2f1cfac8 (diff) | |
download | frameworks_base-645434fb4eff408698423d70904fb8fc709a5225.zip frameworks_base-645434fb4eff408698423d70904fb8fc709a5225.tar.gz frameworks_base-645434fb4eff408698423d70904fb8fc709a5225.tar.bz2 |
Merge "Fix a leak in RefBase" into honeycomb-mr2
-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 7de2633..ae55a61 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; + } } } |