connectivity/source/drivers/jdbc/CallableStatement.cxx | 2 connectivity/source/drivers/jdbc/DatabaseMetaData.cxx | 56 +++++++++-------- connectivity/source/drivers/jdbc/InputStream.cxx | 2 connectivity/source/drivers/jdbc/Object.cxx | 12 +++ connectivity/source/drivers/jdbc/Reader.cxx | 2 connectivity/source/drivers/jdbc/ResultSet.cxx | 2 connectivity/source/drivers/jdbc/ResultSetMetaData.cxx | 10 +-- connectivity/source/inc/java/lang/Object.hxx | 3 connectivity/source/inc/java/sql/DatabaseMetaData.hxx | 3 editeng/source/xml/xmltxtexp.cxx | 1 editeng/source/xml/xmltxtimp.cxx | 1 filter/source/graphicfilter/etiff/etiff.cxx | 8 -- filter/source/graphicfilter/ipcx/ipcx.cxx | 5 - include/sfx2/docfile.hxx | 18 ++--- sfx2/source/appl/appinit.cxx | 8 +- sfx2/source/doc/docfile.cxx | 13 --- svx/source/xml/xmlxtexp.cxx | 1 sw/source/filter/ww8/ww8par2.cxx | 28 ++++---- sw/source/filter/ww8/ww8scan.cxx | 21 +++++- sw/source/filter/ww8/ww8toolbar.cxx | 4 - vcl/source/control/ilstbox.cxx | 2 21 files changed, 108 insertions(+), 94 deletions(-)
New commits: commit cb4cb0c053d257d231bdd3e5eaeb3e1c08aac036 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 10:58:30 2014 +0100 one of the oddest things I've seen Change-Id: Ia0240d212a39401ea119588f4a0731b2b99d1d1f diff --git a/filter/source/graphicfilter/etiff/etiff.cxx b/filter/source/graphicfilter/etiff/etiff.cxx index 8d9cc0f..e265c9f 100644 --- a/filter/source/graphicfilter/etiff/etiff.cxx +++ b/filter/source/graphicfilter/etiff/etiff.cxx @@ -147,20 +147,12 @@ TIFFWriter::TIFFWriter(SvStream &rStream) { } - - TIFFWriter::~TIFFWriter() { } - - bool TIFFWriter::WriteTIFF( const Graphic& rGraphic, FilterConfigItem* pFilterConfigItem) { - sal_uLong* pDummy = new sal_uLong; delete pDummy; // So that under OS/2 - // the right (tools-)new - // is used. Otherwise only vector - // exist within this dll. if ( pFilterConfigItem ) { xStatusIndicator = pFilterConfigItem->GetStatusIndicator(); diff --git a/filter/source/graphicfilter/ipcx/ipcx.cxx b/filter/source/graphicfilter/ipcx/ipcx.cxx index 32dc0d9..283cdeb 100644 --- a/filter/source/graphicfilter/ipcx/ipcx.cxx +++ b/filter/source/graphicfilter/ipcx/ipcx.cxx @@ -93,11 +93,6 @@ bool PCXReader::ReadPCX(Graphic & rGraphic) if ( m_rPCX.GetError() ) return false; - sal_uLong* pDummy = new sal_uLong; delete pDummy; // to achive that under OS/2 - // the right (Tools-) new is used - // otherwise there are only Vector-news - // in this DLL - m_rPCX.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN); // read header: commit 569bf818cb5abfcfbe70eed19a5f8eb0aacc6395 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 11:10:57 2014 +0100 fix indent Change-Id: If9f7154b204a1f5c0a0c6475988cf965fb5aadfe diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx index 35be1a7..8ef92b5 100644 --- a/sw/source/filter/ww8/ww8toolbar.cxx +++ b/sw/source/filter/ww8/ww8toolbar.cxx @@ -1143,7 +1143,7 @@ MacroNames::MacroNames( bool bReadId ) : Tcg255SubStruct( bReadId ) MacroNames::~MacroNames() { - delete[] rgNames; + delete[] rgNames; } bool MacroNames::Read( SvStream &rS) commit 169433f2945865c49402c43808b114d742a27d0b Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 11:10:14 2014 +0100 coverity#1242817 Untrusted loop bound Change-Id: I974a80644f70c024f93d081a87204df8cadfa012 diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx index ffb210b..35be1a7 100644 --- a/sw/source/filter/ww8/ww8toolbar.cxx +++ b/sw/source/filter/ww8/ww8toolbar.cxx @@ -1105,6 +1105,8 @@ bool TcgSttbfCore::Read( SvStream& rS ) rS.ReadUInt16( fExtend ).ReadUInt16( cData ).ReadUInt16( cbExtra ); if ( cData ) { + if (cData > rS.remainingSize() / 4) //definitely an invalid record + return false; dataItems = new SBBItem[ cData ]; for ( sal_Int32 index = 0; index < cData; ++index ) { commit 1c118a9536ab7965bb7c3eedd312987ab224385b Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 11:04:58 2014 +0100 coverity#1242879 Untrusted value as argument Change-Id: Iedcd30fc27e9984407c6752577a3ecb35d7dc075 diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index d12a40d..1df4c60 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -3470,7 +3470,13 @@ void WW8PLCFx_SEPX::GetSprms(WW8PLCFxDesc* p) nSprmSiz = nSiz; } else + { pStrm->ReadUInt16( nSprmSiz ); + } + + sal_Size nRemaining = pStrm->remainingSize(); + if (nSprmSiz > nRemaining) + nSprmSiz = nRemaining; if( nSprmSiz > nArrMax ) { // does not fit commit 159ea0e04e0e284da14b474fc88546bedbf47ba2 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 10:52:40 2014 +0100 coverity#1242719 Untrusted value as argument Change-Id: I444233dcf0a1e5e3792089be605b340b24882c89 diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 752c78e..d12a40d 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -2565,12 +2565,21 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(ww::WordVersion eVersion, SvStream* pSt, { sal_uInt32 nCurr = pDataSt->Tell(); sal_uInt32 nPos = SVBT32ToUInt32(aEntry.mpData + 2); - if (checkSeek(*pDataSt, nPos)) + sal_uInt16 nLen(0); + + bool bOk = checkSeek(*pDataSt, nPos); + if (bOk) + { + pDataSt->ReadUInt16( nLen ); + bOk = nLen <= pDataSt->remainingSize(); + } + + if (bOk) { const sal_uInt16 nOrigLen = bExpand ? aEntry.mnLen : 0; sal_uInt8 *pOrigData = bExpand ? aEntry.mpData : 0; - pDataSt->ReadUInt16( aEntry.mnLen ); + aEntry.mnLen = nLen; aEntry.mpData = new sal_uInt8[aEntry.mnLen + nOrigLen]; aEntry.mbMustDelete = true; commit e178c45a47c394fe50463aeee9e7996a7c03277f Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 10:45:30 2014 +0100 coverity#1242692 Untrusted value as argument Change-Id: If0019caa34168b758f23e88363b94e91f8bd4c8a diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 7d889bf..752c78e 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -1570,6 +1570,8 @@ WW8PLCFpcd* WW8ScannerBase::OpenPieceTable( SvStream* pStr, const WW8Fib* pWwF ) return NULL; // gone wrong if( 1 == clxt ) // clxtGrpprl ? { + if (nLen > pStr->remainingSize()) + return NULL; sal_uInt8* p = new sal_uInt8[nLen+2]; // allocate ShortToSVBT16(nLen, p); // trage Laenge ein if (!checkRead(*pStr, p+2, nLen)) // read grpprl commit 0fc5d67a84cc1d5881765d51fe14416686efe2d1 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 10:40:37 2014 +0100 fix up indent Change-Id: Icaa9b84aa0c3617248d8e52fcccfca928accaea1 diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 5c94876..8d2758e 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -4173,16 +4173,16 @@ void WW8RStyle::ImportOldFormatStyles() rtl_TextEncoding eStructChrSet = WW8Fib::GetFIBCharset( pIo->pWwFib->chseTables); - sal_uInt16 cstcStd; + sal_uInt16 cstcStd(0); rSt.ReadUInt16( cstcStd ); - sal_uInt16 cbName; + sal_uInt16 cbName(0); rSt.ReadUInt16( cbName ); sal_uInt16 nByteCount = 2; sal_uInt16 stcp=0; while (nByteCount < cbName) { - sal_uInt8 nCount; + sal_uInt8 nCount(0); rSt.ReadUChar( nCount ); nByteCount++; @@ -4226,14 +4226,14 @@ void WW8RStyle::ImportOldFormatStyles() sal_uInt16 nStyles=stcp; std::vector<pxoffset> aCHPXOffsets(stcp); - sal_uInt16 cbChpx; + sal_uInt16 cbChpx(0); rSt.ReadUInt16( cbChpx ); nByteCount = 2; stcp=0; std::vector< std::vector<sal_uInt8> > aConvertedChpx; while (nByteCount < cbChpx) { - sal_uInt8 cb; + sal_uInt8 cb(0); rSt.ReadUChar( cb ); nByteCount++; @@ -4257,20 +4257,20 @@ void WW8RStyle::ImportOldFormatStyles() stcp++; if (stcp == nStyles) - { + { rSt.SeekRel(cbChpx-nByteCount); nByteCount += cbChpx-nByteCount; - } + } } std::vector<pxoffset> aPAPXOffsets(stcp); - sal_uInt16 cbPapx; + sal_uInt16 cbPapx(0); rSt.ReadUInt16( cbPapx ); nByteCount = 2; stcp=0; while (nByteCount < cbPapx) { - sal_uInt8 cb; + sal_uInt8 cb(0); rSt.ReadUChar( cb ); nByteCount++; @@ -4278,7 +4278,7 @@ void WW8RStyle::ImportOldFormatStyles() if (cb != 0xFF) { - sal_uInt8 stc2; + sal_uInt8 stc2(0); rSt.ReadUChar( stc2 ); rSt.SeekRel(6); nByteCount+=7; @@ -4294,20 +4294,20 @@ void WW8RStyle::ImportOldFormatStyles() stcp++; if (stcp == nStyles) - { + { rSt.SeekRel(cbPapx-nByteCount); nByteCount += cbPapx-nByteCount; - } + } } - sal_uInt16 iMac; + sal_uInt16 iMac(0); rSt.ReadUInt16( iMac ); if (iMac > nStyles) iMac = nStyles; for (stcp = 0; stcp < iMac; ++stcp) { - sal_uInt8 stcNext, stcBase; + sal_uInt8 stcNext(0), stcBase(0); rSt.ReadUChar( stcNext ); rSt.ReadUChar( stcBase ); commit 6832d9f0f0ba80b95cb3b25e14365dff5803c4b5 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 10:18:14 2014 +0100 coverity#735333 flush out pointless calls to IsRemote and IsOpen etc. Change-Id: I588d4486071b1e31897d4e6468a2c634d6856832 diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx index a0136a6..b59b3cf 100644 --- a/editeng/source/xml/xmltxtexp.cxx +++ b/editeng/source/xml/xmltxtexp.cxx @@ -419,7 +419,6 @@ void SvxWriteXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection& /* testcode const OUString aURL( "file:///e:/test.xml" ); SfxMedium aMedium( aURL, STREAM_WRITE | STREAM_TRUNC, sal_True ); - aMedium.IsRemote(); uno::Reference<io::XOutputStream> xOut( new utl::OOutputStreamWrapper( *aMedium.GetOutStream() ) ); */ diff --git a/editeng/source/xml/xmltxtimp.cxx b/editeng/source/xml/xmltxtimp.cxx index d15a53f..fe10d8f 100644 --- a/editeng/source/xml/xmltxtimp.cxx +++ b/editeng/source/xml/xmltxtimp.cxx @@ -169,7 +169,6 @@ void SvxReadXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection& r /* testcode const OUString aURL( "file:///e:/test.xml" ); SfxMedium aMedium( aURL, STREAM_READ | STREAM_NOCREATE, sal_True ); - aMedium.IsRemote(); uno::Reference<io::XOutputStream> xOut( new utl::OOutputStreamWrapper( *aMedium.GetOutStream() ) ); aMedium.GetInStream()->Seek( 0 ); diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx index 7d8f1ba..ff3a919 100644 --- a/include/sfx2/docfile.hxx +++ b/include/sfx2/docfile.hxx @@ -127,13 +127,13 @@ public: const INetURLObject& GetURLObject() const; void CheckFileDate( const css::util::DateTime& aInitDate ); - bool DocNeedsFileDateCheck(); + SAL_WARN_UNUSED_RESULT bool DocNeedsFileDateCheck() const; css::util::DateTime GetInitFileDate( bool bIgnoreOldValue ); css::uno::Reference< css::ucb::XContent > GetContent() const; const OUString& GetPhysicalName() const; - bool IsRemote() const; - bool IsOpen() const; // { return aStorage.Is() || pInStream; } + SAL_WARN_UNUSED_RESULT bool IsRemote() const; + SAL_WARN_UNUSED_RESULT bool IsOpen() const; // { return aStorage.Is() || pInStream; } void Download( const Link& aLink = Link()); void SetDoneLink( const Link& rLink ); @@ -167,21 +167,21 @@ public: css::uno::Reference< css::embed::XStorage > GetStorage( bool bCreateTempIfNo = true ); css::uno::Reference< css::embed::XStorage > GetOutputStorage(); void ResetError(); - bool UsesCache() const; + SAL_WARN_UNUSED_RESULT bool UsesCache() const; void SetUsesCache( bool ); - bool IsExpired() const; + SAL_WARN_UNUSED_RESULT bool IsExpired() const; void SetName( const OUString& rName, bool bSetOrigURL = false ); - bool IsAllowedForExternalBrowser() const; - long GetFileVersion() const; + SAL_WARN_UNUSED_RESULT bool IsAllowedForExternalBrowser() const; + SAL_WARN_UNUSED_RESULT long GetFileVersion() const; const css::uno::Sequence < css::util::RevisionTag >& GetVersionList( bool _bNoReload = false ); - bool IsReadOnly(); + SAL_WARN_UNUSED_RESULT bool IsReadOnly() const; // Whether the medium had originally been opened r/o, independent of later // changes via SetOpenMode; used to keep track of the "true" state of the // medium across toggles via SID_EDITDOC (which do change SetOpenMode): - bool IsOriginallyReadOnly() const; + SAL_WARN_UNUSED_RESULT bool IsOriginallyReadOnly() const; css::uno::Reference< css::io::XInputStream > GetInputStream(); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 54bb317..d190925 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -380,13 +380,11 @@ void SfxMedium::CheckFileDate( const util::DateTime& aInitDate ) } } - -bool SfxMedium::DocNeedsFileDateCheck() +bool SfxMedium::DocNeedsFileDateCheck() const { return ( !IsReadOnly() && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) ); } - util::DateTime SfxMedium::GetInitFileDate( bool bIgnoreOldValue ) { if ( ( bIgnoreOldValue || !pImp->m_bGotDateTime ) && !pImp->m_aLogicName.isEmpty() ) @@ -3172,8 +3170,7 @@ bool SfxMedium::SaveVersionList_Impl( bool /*bUseXML*/ ) return false; } - -bool SfxMedium::IsReadOnly() +bool SfxMedium::IsReadOnly() const { // a) ReadOnly filter can't produce read/write contents! bool bReadOnly = ( diff --git a/svx/source/xml/xmlxtexp.cxx b/svx/source/xml/xmlxtexp.cxx index 475cb2c..3c5bb5c 100644 --- a/svx/source/xml/xmlxtexp.cxx +++ b/svx/source/xml/xmlxtexp.cxx @@ -246,7 +246,6 @@ bool SvxXMLXTableExportComponent::save( else { pMedium = new SfxMedium( rURL, STREAM_WRITE | STREAM_TRUNC ); - pMedium->IsRemote(); SvStream* pStream = pMedium->GetOutStream(); if( !pStream ) commit cbc1176c14ae36293a9cb2acb895dc99111145d5 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 10:14:27 2014 +0100 SfxMedium::IsRemote can be made const Change-Id: Id6b14366d11c15ec1440482cfb725e497807fa2e diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx index 132e2ac..7d8f1ba 100644 --- a/include/sfx2/docfile.hxx +++ b/include/sfx2/docfile.hxx @@ -132,7 +132,7 @@ public: css::uno::Reference< css::ucb::XContent > GetContent() const; const OUString& GetPhysicalName() const; - bool IsRemote(); + bool IsRemote() const; bool IsOpen() const; // { return aStorage.Is() || pInStream; } void Download( const Link& aLink = Link()); void SetDoneLink( const Link& rLink ); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 8858245..54bb317 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -2352,20 +2352,16 @@ void SfxMedium::GetMedium_Impl() } } - -bool SfxMedium::IsRemote() +bool SfxMedium::IsRemote() const { return pImp->m_bRemote; } - - void SfxMedium::SetUpdatePickList(bool bVal) { pImp->bUpdatePickList = bVal; } - bool SfxMedium::IsUpdatePickList() const { return pImp->bUpdatePickList; commit 44add3e1f1274410f88ab2c81e4c674a05456f91 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 10:11:12 2014 +0100 coverity#704088 Unchecked return value Change-Id: I0fc00b445db0a6254adbfa335e6971c6787109d5 diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index 8a987f4..ec8eb6b 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -861,7 +861,7 @@ void ImplListBoxWindow::MouseButtonDown( const MouseEvent& rMEvt ) mnCurrentPos = nSelect; mbTrackingSelect = true; bool bCurPosChange = (mnCurrentPos != nSelect); - SelectEntries( nSelect, LET_MBDOWN, rMEvt.IsShift(), rMEvt.IsMod1() ,bCurPosChange); + (void)SelectEntries( nSelect, LET_MBDOWN, rMEvt.IsShift(), rMEvt.IsMod1() ,bCurPosChange); mbTrackingSelect = false; if ( mbGrabFocus ) GrabFocus(); commit b0f26546cece3b1f251c83d29560b09577bfe2f4 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 10:06:43 2014 +0100 coverity#706322 Uncaught exception and coverity#706330 Uncaught exception Change-Id: I105e37c88654cf47b50fe6b260b8994622305dab diff --git a/connectivity/source/drivers/jdbc/CallableStatement.cxx b/connectivity/source/drivers/jdbc/CallableStatement.cxx index 6638b55..a915b8c 100644 --- a/connectivity/source/drivers/jdbc/CallableStatement.cxx +++ b/connectivity/source/drivers/jdbc/CallableStatement.cxx @@ -140,7 +140,7 @@ sal_Int32 SAL_CALL java_sql_CallableStatement::getInt( sal_Int32 columnIndex ) t SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); createStatement(t.pEnv); static jmethodID mID(NULL); - return callIntMethodWithIntArg("getInt",mID,columnIndex); + return callIntMethodWithIntArg_Throw("getInt",mID,columnIndex); } sal_Int64 SAL_CALL java_sql_CallableStatement::getLong( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, RuntimeException, std::exception) diff --git a/connectivity/source/drivers/jdbc/InputStream.cxx b/connectivity/source/drivers/jdbc/InputStream.cxx index 41afbe8..f1cba90 100644 --- a/connectivity/source/drivers/jdbc/InputStream.cxx +++ b/connectivity/source/drivers/jdbc/InputStream.cxx @@ -62,7 +62,7 @@ sal_Int32 SAL_CALL java_io_InputStream::readSomeBytes( ::com::sun::star::uno::Se void SAL_CALL java_io_InputStream::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) { static jmethodID mID(NULL); - callIntMethodWithIntArg("skip",mID,nBytesToSkip); + callIntMethodWithIntArg_Nothrow("skip",mID,nBytesToSkip); } sal_Int32 SAL_CALL java_io_InputStream::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx index 37c8a41..5ca638f 100644 --- a/connectivity/source/drivers/jdbc/Object.cxx +++ b/connectivity/source/drivers/jdbc/Object.cxx @@ -284,7 +284,7 @@ sal_Int32 java_lang_Object::callIntMethod_Nothrow(const char* _pMethodName, jmet return (sal_Int32)out; } -sal_Int32 java_lang_Object::callIntMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nArgument ) const +sal_Int32 java_lang_Object::callIntMethodWithIntArg_Throw( const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nArgument ) const { SDBThreadAttach t; OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" ); @@ -292,7 +292,17 @@ sal_Int32 java_lang_Object::callIntMethodWithIntArg( const char* _pMethodName, j // call method jint out( t.pEnv->CallIntMethod( object, _inout_MethodID , _nArgument) ); ThrowSQLException( t.pEnv, NULL ); + return (sal_Int32)out; +} +sal_Int32 java_lang_Object::callIntMethodWithIntArg_Nothrow( const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nArgument ) const +{ + SDBThreadAttach t; + OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" ); + obtainMethodId(t.pEnv, _pMethodName,"(I)I", _inout_MethodID); + // call method + jint out( t.pEnv->CallIntMethod( object, _inout_MethodID , _nArgument) ); + isExceptionOccurred(t.pEnv,true); return (sal_Int32)out; } diff --git a/connectivity/source/drivers/jdbc/Reader.cxx b/connectivity/source/drivers/jdbc/Reader.cxx index 3907da7..b62da3a 100644 --- a/connectivity/source/drivers/jdbc/Reader.cxx +++ b/connectivity/source/drivers/jdbc/Reader.cxx @@ -52,7 +52,7 @@ sal_Int32 SAL_CALL java_io_Reader::readSomeBytes( ::com::sun::star::uno::Sequenc void SAL_CALL java_io_Reader::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) { static jmethodID mID(NULL); - callIntMethodWithIntArg("skip",mID,nBytesToSkip); + callIntMethodWithIntArg_Nothrow("skip",mID,nBytesToSkip); } sal_Int32 SAL_CALL java_io_Reader::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx index 279f944..0f20a75 100644 --- a/connectivity/source/drivers/jdbc/ResultSet.cxx +++ b/connectivity/source/drivers/jdbc/ResultSet.cxx @@ -217,7 +217,7 @@ float SAL_CALL java_sql_ResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLEx sal_Int32 SAL_CALL java_sql_ResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return callIntMethodWithIntArg("getInt",mID,columnIndex); + return callIntMethodWithIntArg_Throw("getInt",mID,columnIndex); } diff --git a/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx b/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx index 91c548a..6dcd5da 100644 --- a/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx +++ b/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx @@ -58,14 +58,14 @@ jclass java_sql_ResultSetMetaData::getMyClass() const sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return callIntMethodWithIntArg("getColumnDisplaySize",mID,column); + return callIntMethodWithIntArg_Throw("getColumnDisplaySize",mID,column); } sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return callIntMethodWithIntArg("getColumnType",mID,column); + return callIntMethodWithIntArg_Throw("getColumnType",mID,column); } @@ -157,19 +157,19 @@ sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSigned( sal_Int32 column ) throw sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return callIntMethodWithIntArg("getPrecision",mID,column); + return callIntMethodWithIntArg_Throw("getPrecision",mID,column); } sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) { static jmethodID mID(NULL); - return callIntMethodWithIntArg("getScale",mID,column); + return callIntMethodWithIntArg_Throw("getScale",mID,column); } sal_Int32 SAL_CALL java_sql_ResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return callIntMethodWithIntArg("isNullable",mID,column); + return callIntMethodWithIntArg_Throw("isNullable",mID,column); } diff --git a/connectivity/source/inc/java/lang/Object.hxx b/connectivity/source/inc/java/lang/Object.hxx index cf46e58..28b4e43 100644 --- a/connectivity/source/inc/java/lang/Object.hxx +++ b/connectivity/source/inc/java/lang/Object.hxx @@ -116,7 +116,8 @@ namespace connectivity jobject callResultSetMethod( JNIEnv& _rEnv, const char* _pMethodName, jmethodID& _inout_MethodID ) const; sal_Int32 callIntMethod_Throw(const char* _pMethodName, jmethodID& _inout_MethodID) const; sal_Int32 callIntMethod_Nothrow(const char* _pMethodName, jmethodID& _inout_MethodID) const; - sal_Int32 callIntMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; + sal_Int32 callIntMethodWithIntArg_Throw( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; + sal_Int32 callIntMethodWithIntArg_Nothrow( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; sal_Int32 callIntMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const OUString& _nArgument ) const; OUString callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const; OUString callStringMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const; commit 405a61f916ba3da4f2fa9d27ab4f0cc287eed1a6 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Oct 15 10:00:43 2014 +0100 coverity#706318 Uncaught exception and coverity#706317 Uncaught exception Change-Id: Idd01f4ba68b1ce6590d6c7b79bcff9593f0766ea diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx index 63b73cd..2b7e5e6 100644 --- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx @@ -241,73 +241,73 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getVersionColumns( sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxBinaryLiteralLength", mID); + return impl_callIntMethod_Throw("getMaxBinaryLiteralLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxRowSize", mID); + return impl_callIntMethod_Throw("getMaxRowSize", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxCatalogNameLength", mID); + return impl_callIntMethod_Throw("getMaxCatalogNameLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxCharLiteralLength", mID); + return impl_callIntMethod_Throw("getMaxCharLiteralLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxColumnNameLength", mID); + return impl_callIntMethod_Throw("getMaxColumnNameLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxColumnsInIndex", mID); + return impl_callIntMethod_Throw("getMaxColumnsInIndex", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxCursorNameLength", mID); + return impl_callIntMethod_Throw("getMaxCursorNameLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxConnections", mID); + return impl_callIntMethod_Throw("getMaxConnections", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxColumnsInTable", mID); + return impl_callIntMethod_Throw("getMaxColumnsInTable", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxStatementLength", mID); + return impl_callIntMethod_Throw("getMaxStatementLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxTableNameLength", mID); + return impl_callIntMethod_Throw("getMaxTableNameLength", mID); } sal_Int32 java_sql_DatabaseMetaData::impl_getMaxTablesInSelect_throw( ) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxTablesInSelect", mID); + return impl_callIntMethod_Throw("getMaxTablesInSelect", mID); } Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getExportedKeys( @@ -563,8 +563,7 @@ OUString java_sql_DatabaseMetaData::impl_callStringMethod( const char* _pMethodN return sReturn; } - -sal_Int32 java_sql_DatabaseMetaData::impl_callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) +sal_Int32 java_sql_DatabaseMetaData::impl_callIntMethod_Throw(const char* _pMethodName, jmethodID& _inout_MethodID) { m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName ); sal_Int32 out( (sal_Int32)callIntMethod_Throw(_pMethodName,_inout_MethodID) ); @@ -572,6 +571,13 @@ sal_Int32 java_sql_DatabaseMetaData::impl_callIntMethod( const char* _pMethodNam return out; } +sal_Int32 java_sql_DatabaseMetaData::impl_callIntMethod_Nothrow(const char* _pMethodName, jmethodID& _inout_MethodID) +{ + m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName ); + sal_Int32 out( (sal_Int32)callIntMethod_Nothrow(_pMethodName,_inout_MethodID) ); + m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, (sal_Int32)out ); + return out; +} bool java_sql_DatabaseMetaData::impl_callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) { @@ -722,7 +728,7 @@ bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( ) sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxIndexLength", mID); + return impl_callIntMethod_Throw("getMaxIndexLength", mID); } sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException, std::exception) @@ -896,19 +902,19 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTableTypes( ) th sal_Int32 java_sql_DatabaseMetaData::impl_getMaxStatements_throw( ) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxStatements", mID); + return impl_callIntMethod_Throw("getMaxStatements", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxProcedureNameLength", mID); + return impl_callIntMethod_Throw("getMaxProcedureNameLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxSchemaNameLength", mID); + return impl_callIntMethod_Throw("getMaxSchemaNameLength", mID); } sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException, std::exception) @@ -1215,19 +1221,19 @@ OUString SAL_CALL java_sql_DatabaseMetaData::getSchemaTerm( ) throw(SQLExceptio sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getDriverMajorVersion", mID); + return impl_callIntMethod_Nothrow("getDriverMajorVersion", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getDefaultTransactionIsolation", mID); + return impl_callIntMethod_Throw("getDefaultTransactionIsolation", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getDriverMinorVersion", mID); + return impl_callIntMethod_Nothrow("getDriverMinorVersion", mID); } OUString SAL_CALL java_sql_DatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException, std::exception) @@ -1299,25 +1305,25 @@ sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLimitedOuterJoins( ) throw sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxColumnsInGroupBy", mID); + return impl_callIntMethod_Throw("getMaxColumnsInGroupBy", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxColumnsInOrderBy", mID); + return impl_callIntMethod_Throw("getMaxColumnsInOrderBy", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxColumnsInSelect", mID); + return impl_callIntMethod_Throw("getMaxColumnsInSelect", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod("getMaxUserNameLength", mID); + return impl_callIntMethod_Throw("getMaxUserNameLength", mID); } sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException, std::exception) diff --git a/connectivity/source/inc/java/sql/DatabaseMetaData.hxx b/connectivity/source/inc/java/sql/DatabaseMetaData.hxx index 84f077f..bd704a8 100644 --- a/connectivity/source/inc/java/sql/DatabaseMetaData.hxx +++ b/connectivity/source/inc/java/sql/DatabaseMetaData.hxx @@ -202,7 +202,8 @@ namespace connectivity private: bool impl_callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ); OUString impl_callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ); - sal_Int32 impl_callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID ); + sal_Int32 impl_callIntMethod_Throw( const char* _pMethodName, jmethodID& _inout_MethodID ); + sal_Int32 impl_callIntMethod_Nothrow( const char* _pMethodName, jmethodID& _inout_MethodID ); bool impl_callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ); ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_callResultSetMethod( const char* _pMethodName, jmethodID& _inout_MethodID ); commit 7f7d2213209dd8e23292ec5a85fbab6127824c49 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Oct 13 10:25:26 2014 +0100 osl_Module -> osl::Module related coverity#1242504 Resource leak but it still leaks a dlopen handle here of course Change-Id: Iaf692e7b2753c1c0af580e236bc147dc30a39e9f diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx index f5a4682..dfbed1e 100644 --- a/sfx2/source/appl/appinit.cxx +++ b/sfx2/source/appl/appinit.cxx @@ -178,14 +178,14 @@ OUString GetSpecialCharsForEdit(vcl::Window* pParent, const vcl::Font& rFont) bDetermineFunction = true; #ifndef DISABLE_DYNLOADING - static OUString aLibName( SVLIBRARY( "cui" ) ); - oslModule handleMod = osl_loadModuleRelative( - &thisModule, aLibName.pData, 0 ); + osl::Module aMod; + aMod.loadRelative(&thisModule, "cui", 0); // get symbol OUString aSymbol( "GetSpecialCharsForEdit" ); - pfunc_getSpecialCharsForEdit = (PFunc_getSpecialCharsForEdit)osl_getFunctionSymbol( handleMod, aSymbol.pData ); + pfunc_getSpecialCharsForEdit = (PFunc_getSpecialCharsForEdit)aMod.getFunctionSymbol(aSymbol); DBG_ASSERT( pfunc_getSpecialCharsForEdit, "GetSpecialCharsForEdit() not found!" ); + aMod.release(); #else pfunc_getSpecialCharsForEdit = GetSpecialCharsForEdit; #endif
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits