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
This commit is contained in:
Mathias Agopian 2011-06-08 16:05:30 -07:00
parent 1c251f9d9a
commit 3b0a7a739e
1 changed files with 10 additions and 6 deletions

View File

@ -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;
}
}
}