Kaydet (Commit) 28e1f3c7 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Noel Grandin

svl: Fix possible memleak at deleting DdeService

Change-Id: Ie10d4199999c4331af29dee2a8d98132488caa6e
Reviewed-on: https://gerrit.libreoffice.org/44909Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 67bd9382
......@@ -48,7 +48,7 @@ struct Conversation;
typedef ::std::vector< DdeService* > DdeServices;
typedef ::std::vector< long > DdeFormats;
typedef ::std::vector< Conversation* > ConvList;
typedef std::vector<std::unique_ptr<Conversation>> ConvList;
class SVL_DLLPUBLIC DdeData
......@@ -297,7 +297,7 @@ private:
DdeFormats aFormats;
DdeTopic* pSysTopic;
DdeString* pName;
ConvList* pConv;
ConvList m_vConv;
short nStatus;
SVL_DLLPRIVATE bool HasCbFormat( sal_uInt16 );
......@@ -306,6 +306,9 @@ public:
DdeService( SAL_UNUSED_PARAMETER const OUString& );
virtual ~DdeService();
DdeService( const DdeService& ) = delete;
DdeService& operator= ( const DdeService& ) = delete;
const OUString GetName() const;
short GetError() { return nStatus; }
......
......@@ -37,8 +37,6 @@ struct Conversation
DdeTopic* pTopic;
};
typedef ::std::vector< Conversation* > ConvList;
class DdeInternal
{
......
......@@ -153,7 +153,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
pC = new Conversation;
pC->hConv = hConv;
pC->pTopic = pTopic;
pService->pConv->push_back( pC );
pService->m_vConv.emplace_back( pC );
}
}
return nullptr;
......@@ -162,9 +162,9 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
for (DdeServices::iterator aI = rAll.begin(); aI != rAll.end(); ++aI)
{
pService = *aI;
for ( size_t i = 0, n = pService->pConv->size(); i < n; ++i )
for ( size_t i = 0, n = pService->m_vConv.size(); i < n; ++i )
{
pC = (*pService->pConv)[ i ];
pC = pService->m_vConv[ i ].get();
if ( pC->hConv == hConv )
goto found;
}
......@@ -176,14 +176,13 @@ found:
if ( nCode == XTYP_DISCONNECT)
{
DisconnectTopic(*pC->pTopic, hConv);
for ( ConvList::iterator it = pService->pConv->begin();
it != pService->pConv->end();
for ( ConvList::iterator it = pService->m_vConv.begin();
it != pService->m_vConv.end();
++it
) {
if ( *it == pC )
if ( it->get() == pC )
{
delete *it;
pService->pConv->erase( it );
pService->m_vConv.erase( it );
break;
}
}
......@@ -435,8 +434,6 @@ DdeService::DdeService( const OUString& rService )
else
nStatus = DMLERR_NO_ERROR;
pConv = new ConvList;
if ( pInst->pServicesSvr )
pInst->pServicesSvr->push_back( this );
......@@ -482,7 +479,6 @@ DdeService::~DdeService()
ImpDeinitInstData();
}
}
delete pConv;
}
const OUString DdeService::GetName() const
......@@ -513,16 +509,11 @@ void DdeService::RemoveTopic( const DdeTopic& rTopic )
aTopics.erase(iter);
// Delete all conversions!
// Or else we work on deleted topics!
for( size_t n = pConv->size(); n; )
for( size_t n = m_vConv.size(); n; )
{
Conversation* pC = (*pConv)[ --n ];
auto const& pC = m_vConv[ --n ];
if( pC->pTopic == &rTopic )
{
ConvList::iterator it = pConv->begin();
::std::advance( it, n );
delete *it;
pConv->erase( it );
}
m_vConv.erase( m_vConv.begin() + n );
}
break;
}
......
......@@ -20,6 +20,10 @@
#include <svl/svdde.hxx>
#include <rtl/instance.hxx>
struct Conversation
{
};
struct DdeDataImp
{
};
......@@ -202,7 +206,6 @@ const OUString DdeTopic::GetName() const
DdeService::DdeService( const OUString& )
: pSysTopic(nullptr)
, pName(nullptr)
, pConv(nullptr)
, nStatus(0)
{
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment