diff options
| author | 2011-02-25 16:11:44 -0800 | |
|---|---|---|
| committer | 2011-02-25 16:20:52 -0800 | |
| commit | 32bebb0a58dd9c699aed8045ca2e752f681e5a0f (patch) | |
| tree | 9d22fe196138cf4fea219d84c12772df9cd9c05a /include/utils/StrongPointer.h | |
| parent | c614e553cc4b93443c30d1ec728997c293ba024d (diff) | |
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/StrongPointer.h')
| -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 a8c989749b..49fa3a8d6f 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; |