diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-10-08 15:50:04 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-10-08 20:45:14 +0100 |
commit | 6707c7514db24d05ff76498f76fd48cf07a00fb6 (patch) | |
tree | 36f815c8ba74634a3706316a99e79a94763b2a62 | |
parent | d7606a6ab588d9abd9bf8a2f7d8bfc798c449507 (diff) |
coverity#1066165 Resource leak
no close on error paths
Change-Id: Ie544bcd6ea7224bee2a092013a589c509d42c735
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 96133718a415..bbacab86c9b7 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -37,7 +37,7 @@ #include <comphelper/string.hxx> #include <cppuhelper/implbase1.hxx> #include <i18nlangtag/languagetag.hxx> -#include <osl/file.h> +#include <osl/file.hxx> #include <osl/thread.h> #include <rtl/crc.h> #include <rtl/digest.h> @@ -3887,13 +3887,13 @@ bool PDFWriterImpl::emitFonts() if( m_pReferenceDevice->mpGraphics->CreateFontSubset( aTmpName, it->first, aGlyphIds, pEncoding, pWidths, nGlyphs, aSubsetInfo ) ) { // create font stream - oslFileHandle aFontFile; - if ( osl_File_E_None != osl_openFile( aTmpName.pData, &aFontFile, osl_File_OpenFlag_Read ) ) return false; + osl::File aFontFile(aTmpName); + if (osl::File::E_None != aFontFile.open(osl_File_OpenFlag_Read)) return false; // get file size sal_uInt64 nLength1; - if ( osl_File_E_None != osl_setFilePos( aFontFile, osl_Pos_End, 0 ) ) return false; - if ( osl_File_E_None != osl_getFilePos( aFontFile, &nLength1 ) ) return false; - if ( osl_File_E_None != osl_setFilePos( aFontFile, osl_Pos_Absolut, 0 ) ) return false; + if ( osl::File::E_None != aFontFile.setPos(osl_Pos_End, 0) ) return false; + if ( osl::File::E_None != aFontFile.getPos(nLength1) ) return false; + if ( osl::File::E_None != aFontFile.setPos(osl_Pos_Absolut, 0) ) return false; #if OSL_DEBUG_LEVEL > 1 emitComment( "PDFWriterImpl::emitFonts" ); @@ -3930,9 +3930,9 @@ bool PDFWriterImpl::emitFonts() { char buf[8192]; sal_uInt64 nRead; - if ( osl_File_E_None != osl_readFile( aFontFile, buf, sizeof( buf ), &nRead ) ) return false; + if ( osl::File::E_None != aFontFile.read(buf, sizeof(buf), nRead) ) return false; if ( !writeBuffer( buf, nRead ) ) return false; - if ( osl_File_E_None != osl_isEndOfFile( aFontFile, &bEOF ) ) return false; + if ( osl::File::E_None != aFontFile.isEndOfFile(&bEOF) ) return false; } while( ! bEOF ); } else if( (aSubsetInfo.m_nFontType & FontSubsetInfo::CFF_FONT) != 0 ) @@ -3945,9 +3945,9 @@ bool PDFWriterImpl::emitFonts() boost::shared_array<unsigned char> pBuffer( new unsigned char[ nLength1 ] ); sal_uInt64 nBytesRead = 0; - if ( osl_File_E_None != osl_readFile( aFontFile, pBuffer.get(), nLength1, &nBytesRead ) ) return false; + if ( osl::File::E_None != aFontFile.read(pBuffer.get(), nLength1, nBytesRead) ) return false; DBG_ASSERT( nBytesRead==nLength1, "PDF-FontSubset read incomplete!" ); - if ( osl_File_E_None != osl_setFilePos( aFontFile, osl_Pos_Absolut, 0 ) ) return false; + if ( osl::File::E_None != aFontFile.setPos(osl_Pos_Absolut, 0) ) return false; // get the PFB-segment lengths ThreeInts aSegmentLengths = {0,0,0}; getPfbSegmentLengths( pBuffer.get(), (int)nBytesRead, aSegmentLengths ); @@ -3980,7 +3980,7 @@ bool PDFWriterImpl::emitFonts() endCompression(); disableStreamEncryption(); // close the file - osl_closeFile( aFontFile ); + aFontFile.close(); sal_uInt64 nEndPos = 0; if ( osl_File_E_None != osl_getFilePos( m_aFile, &nEndPos ) ) return false; |