summaryrefslogtreecommitdiff
path: root/extensions/source/plugin/unx
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-04-02 16:08:04 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-04-02 16:09:11 +0900
commit8f7c677dbba29123c48778a1024a535f36bca183 (patch)
tree3123165f84a6bd7475d7311e75f59eed18b14450 /extensions/source/plugin/unx
parent7fcab08f36fe8bceeab7235e3b83cddeb06fd103 (diff)
Avoid possible resource leaks by boost::scoped_array
Change-Id: Ibf92b3098c50388d8b6d27f4476e613a1f8918b5
Diffstat (limited to 'extensions/source/plugin/unx')
-rw-r--r--extensions/source/plugin/unx/mediator.cxx13
1 files changed, 6 insertions, 7 deletions
diff --git a/extensions/source/plugin/unx/mediator.cxx b/extensions/source/plugin/unx/mediator.cxx
index a4eea38df1b1..347f5e2a94d0 100644
--- a/extensions/source/plugin/unx/mediator.cxx
+++ b/extensions/source/plugin/unx/mediator.cxx
@@ -32,6 +32,7 @@
#include <plugin/unx/mediator.hxx>
#include <sal/log.hxx>
#include <vcl/svapp.hxx>
+#include <boost/scoped_array.hpp>
#define MEDIATOR_MAGIC 0xf7a8d2f4
@@ -93,15 +94,14 @@ sal_uLong Mediator::SendMessage( sal_uLong nBytes, const char* pBytes, sal_uLong
if( ! m_bValid )
return nMessageID;
- sal_uLong* pBuffer = new sal_uLong[ (nBytes/sizeof(sal_uLong)) + 4 ];
+ boost::scoped_array<sal_uLong> pBuffer(new sal_uLong[ (nBytes/sizeof(sal_uLong)) + 4 ]);
pBuffer[ 0 ] = nMessageID;
pBuffer[ 1 ] = nBytes;
pBuffer[ 2 ] = MEDIATOR_MAGIC;
memcpy( &pBuffer[3], pBytes, (size_t)nBytes );
ssize_t nToWrite = nBytes + 3*sizeof( sal_uLong );
- bool bSuccess = (nToWrite == write( m_nSocket, pBuffer, nToWrite ));
+ bool bSuccess = (nToWrite == write( m_nSocket, pBuffer.get(), nToWrite ));
SAL_WARN_IF(!bSuccess, "extensions.plugin", "short write");
- delete [] pBuffer;
return nMessageID;
}
@@ -206,15 +206,15 @@ void MediatorListener::run()
{
if( nHeader[ 0 ] == 0 && nHeader[ 1 ] == 0 )
return;
- char* pBuffer = new char[ nHeader[ 1 ] ];
- if( m_pMediator && (sal_uLong)read( m_pMediator->m_nSocket, pBuffer, nHeader[ 1 ] ) == nHeader[ 1 ] )
+ boost::scoped_array<char> pBuffer(new char[ nHeader[ 1 ] ]);
+ if( m_pMediator && (sal_uLong)read( m_pMediator->m_nSocket, pBuffer.get(), nHeader[ 1 ] ) == nHeader[ 1 ] )
{
::osl::MutexGuard aMyGuard( m_aMutex );
{
osl::MutexGuard
aGuard( m_pMediator->m_aQueueMutex );
MediatorMessage* pMessage =
- new MediatorMessage( nHeader[ 0 ], nHeader[ 1 ], pBuffer );
+ new MediatorMessage( nHeader[ 0 ], nHeader[ 1 ], pBuffer.get() );
m_pMediator->m_aMessageQueue.push_back( pMessage );
}
m_pMediator->m_aNewMessageCdtn.set();
@@ -228,7 +228,6 @@ void MediatorListener::run()
<< nHeader[1] << ", ... }");
bRun = false;
}
- delete [] pBuffer;
}
else
{