mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-22 23:11:00 +01:00
Merge pull request #452 from Kontinuation/develop
Fixed possible memory leak in SharedPtr (issue #287)
This commit is contained in:
commit
c26eb63a5e
@ -119,9 +119,14 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
SharedPtr(C* ptr): _pCounter(new RC), _ptr(ptr)
|
||||
SharedPtr(C* ptr)
|
||||
try :
|
||||
_pCounter(new RC), _ptr(ptr)
|
||||
{
|
||||
}
|
||||
catch (...) {
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
template <class Other, class OtherRP>
|
||||
SharedPtr(const SharedPtr<Other, RC, OtherRP>& ptr): _pCounter(ptr._pCounter), _ptr(const_cast<Other*>(ptr.get()))
|
||||
@ -143,10 +148,8 @@ public:
|
||||
{
|
||||
if (get() != ptr)
|
||||
{
|
||||
RC* pTmp = new RC;
|
||||
release();
|
||||
_pCounter = pTmp;
|
||||
_ptr = ptr;
|
||||
SharedPtr tmp(ptr);
|
||||
swap(tmp);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user