diff options
author | Mathias Agopian <mathias@google.com> | 2011-02-25 16:11:44 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2011-02-25 16:20:52 -0800 |
commit | 32a55cf66e12e5e56d2e05b73c6bef453477c2bb (patch) | |
tree | e5709c24f92bc304bfc32f75b8f23911092c5f40 /include/utils | |
parent | d752c3b3e6c576ed1f18e86a7b18c33dc7c65791 (diff) | |
download | frameworks_base-32a55cf66e12e5e56d2e05b73c6bef453477c2bb.zip frameworks_base-32a55cf66e12e5e56d2e05b73c6bef453477c2bb.tar.gz frameworks_base-32a55cf66e12e5e56d2e05b73c6bef453477c2bb.tar.bz2 |
Fix sp<> conversion operator / constructor
some of the conversion operators were not using the proper
pointer type when calling incStrong/decStrong, usually it
has no bad consequences, but for some implementation
of the ref-counted object it could lead to recording the wrong
owner id.
Change-Id: If574b9069b8a4cf6e0911a992c8f095aba799995
Diffstat (limited to 'include/utils')
-rw-r--r-- | include/utils/StrongPointer.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/utils/StrongPointer.h b/include/utils/StrongPointer.h index a8c9897..49fa3a8 100644 --- a/include/utils/StrongPointer.h +++ b/include/utils/StrongPointer.h @@ -133,7 +133,7 @@ sp<T>::sp(const sp<T>& other) template<typename T> template<typename U> sp<T>::sp(U* other) : m_ptr(other) { - if (other) other->incStrong(this); + if (other) ((T*)other)->incStrong(this); } template<typename T> template<typename U> @@ -170,7 +170,7 @@ sp<T>& sp<T>::operator = (T* other) template<typename T> template<typename U> sp<T>& sp<T>::operator = (const sp<U>& other) { - U* otherPtr(other.m_ptr); + T* otherPtr(other.m_ptr); if (otherPtr) otherPtr->incStrong(this); if (m_ptr) m_ptr->decStrong(this); m_ptr = otherPtr; @@ -180,7 +180,7 @@ sp<T>& sp<T>::operator = (const sp<U>& other) template<typename T> template<typename U> sp<T>& sp<T>::operator = (U* other) { - if (other) other->incStrong(this); + if (other) ((T*)other)->incStrong(this); if (m_ptr) m_ptr->decStrong(this); m_ptr = other; return *this; |