summaryrefslogtreecommitdiff
path: root/vcl/generic
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-03-11 09:24:30 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-03-11 09:30:49 +0900
commit59b428189d14da78e761c8dbb8bd8ba7de4fa511 (patch)
tree2b9c0c9fe9c917a87538173820e92f0631f4e961 /vcl/generic
parentbad51b0613db4a9152ffebe43a74a83af42d532b (diff)
Avoid possible resource leaks by boost::scoped_array
Change-Id: I3a9131d75690e18caec4c328934735a9ca19e7ca
Diffstat (limited to 'vcl/generic')
-rw-r--r--vcl/generic/fontmanager/helper.cxx13
1 files changed, 5 insertions, 8 deletions
diff --git a/vcl/generic/fontmanager/helper.cxx b/vcl/generic/fontmanager/helper.cxx
index 729d5268c0a6..a35264f19b6b 100644
--- a/vcl/generic/fontmanager/helper.cxx
+++ b/vcl/generic/fontmanager/helper.cxx
@@ -31,6 +31,7 @@
#include <tools/urlobj.hxx>
#include "vcl/helper.hxx"
#include "vcl/ppdparser.hxx"
+#include <boost/scoped_array.hpp>
using ::rtl::Bootstrap;
@@ -284,15 +285,15 @@ bool psp::convertPfbToPfa( ::osl::File& rInFile, ::osl::File& rOutFile )
}
else if( nType == 1 || nType == 2 )
{
- unsigned char* pBuffer = new unsigned char[ nBytesToRead+1 ];
+ boost::scoped_array<unsigned char> pBuffer(new unsigned char[ nBytesToRead+1 ]);
- if( ! rInFile.read( pBuffer, nBytesToRead, nRead ) && nRead == nBytesToRead )
+ if( ! rInFile.read( pBuffer.get(), nBytesToRead, nRead ) && nRead == nBytesToRead )
{
if( nType == 1 )
{
// ascii data, convert dos lineends( \r\n ) and
// m_ac lineends( \r ) to \n
- unsigned char * pWriteBuffer = new unsigned char[ nBytesToRead ];
+ boost::scoped_array<unsigned char> pWriteBuffer(new unsigned char[ nBytesToRead ]);
unsigned int nBytesToWrite = 0;
for( unsigned int i = 0; i < nBytesToRead; i++ )
{
@@ -306,10 +307,8 @@ bool psp::convertPfbToPfa( ::osl::File& rInFile, ::osl::File& rOutFile )
else
pWriteBuffer[ nBytesToWrite++ ] = '\n';
}
- if( rOutFile.write( pWriteBuffer, nBytesToWrite, nRead ) || nRead != nBytesToWrite )
+ if( rOutFile.write( pWriteBuffer.get(), nBytesToWrite, nRead ) || nRead != nBytesToWrite )
bSuccess = false;
-
- delete [] pWriteBuffer;
}
else
{
@@ -337,8 +336,6 @@ bool psp::convertPfbToPfa( ::osl::File& rInFile, ::osl::File& rOutFile )
}
else
bSuccess = false;
-
- delete [] pBuffer;
}
else if( nType == 3 )
bEof = true;