summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-06-08 16:05:30 -0700
committerMathias Agopian <mathias@google.com>2011-06-08 16:25:01 -0700
commit2c0042b666a969091c931614f2fc0dce2f1cfac8 (patch)
tree75f1f82ffa4b12252e80ca48edc8ede8113dba4e /libs
parentcea03df201dc6659654234bc5fbfebf1b6a06e42 (diff)
downloadframeworks_base-2c0042b666a969091c931614f2fc0dce2f1cfac8.zip
frameworks_base-2c0042b666a969091c931614f2fc0dce2f1cfac8.tar.gz
frameworks_base-2c0042b666a969091c931614f2fc0dce2f1cfac8.tar.bz2
Fix a leak in RefBase
this bug was introduced recently. it caused RefBase's weakref_impl structure to be leaked for every RefBase object (about 20 bytes). Change-Id: Id85e749ba04521199555dd701198edd097c313d4
Diffstat (limited to 'libs')
-rw-r--r--libs/utils/RefBase.cpp16
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;
+ }
}
}