basic/source/classes/propacc.cxx | 13 ++++------ comphelper/source/property/propagg.cxx | 2 - extensions/source/activex/SOActiveX.cxx | 35 ++++++++++++++++------------ svx/source/smarttags/SmartTagMgr.cxx | 2 - vcl/source/font/font.cxx | 5 +--- writerfilter/source/rtftok/rtftokenizer.cxx | 3 -- 6 files changed, 30 insertions(+), 30 deletions(-)
New commits: commit 35e80e9726b5fee6a00caa58349a4b5d924dad7c Author: Noel Grandin <[email protected]> AuthorDate: Fri Oct 19 16:01:19 2018 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sat Oct 20 08:00:32 2018 +0200 when calling std::lower_bound it's not enough to compare != end(), you also need to compare the key against the iterator result Change-Id: Ide5f151ba2297a35e5546f47fbc3c53cbe5ab533 Reviewed-on: https://gerrit.libreoffice.org/62014 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/basic/source/classes/propacc.cxx b/basic/source/classes/propacc.cxx index 8cc697a76441..a14465599e0a 100644 --- a/basic/source/classes/propacc.cxx +++ b/basic/source/classes/propacc.cxx @@ -38,13 +38,10 @@ using namespace com::sun::star::lang; using namespace com::sun::star::beans; using namespace cppu; -struct SbCompare_UString_PropertyValue_Impl +static bool SbCompare_UString_PropertyValue_Impl(PropertyValue const & lhs, const OUString& rhs) { - bool operator() (PropertyValue const & lhs, const OUString& rhs) - { - return lhs.Name.compareTo(rhs) < 0; - } -}; + return lhs.Name.compareTo(rhs) < 0; +} SbPropertyValues::SbPropertyValues() @@ -82,8 +79,8 @@ size_t SbPropertyValues::GetIndex_Impl( const OUString &rPropName ) const { SbPropertyValueArr_Impl::const_iterator it = std::lower_bound( m_aPropVals.begin(), m_aPropVals.end(), rPropName, - SbCompare_UString_PropertyValue_Impl() ); - if (it == m_aPropVals.end()) + SbCompare_UString_PropertyValue_Impl ); + if (it == m_aPropVals.end() || !SbCompare_UString_PropertyValue_Impl(*it, rPropName)) { throw beans::UnknownPropertyException( "Property not found: " + rPropName, diff --git a/comphelper/source/property/propagg.cxx b/comphelper/source/property/propagg.cxx index d1f6e3a76c17..1e618694f465 100644 --- a/comphelper/source/property/propagg.cxx +++ b/comphelper/source/property/propagg.cxx @@ -239,7 +239,7 @@ sal_Int32 OPropertyArrayAggregationHelper::fillHandles( { aNameProp.Name = pReqProps[i]; auto findIter = std::lower_bound(m_aProperties.begin(), m_aProperties.end(), aNameProp, PropertyCompareByName()); - if ( findIter != m_aProperties.end() ) + if ( findIter != m_aProperties.end() && !PropertyCompareByName()(*findIter, aNameProp)) { _pHandles[i] = findIter->Handle; nHitCount++; diff --git a/svx/source/smarttags/SmartTagMgr.cxx b/svx/source/smarttags/SmartTagMgr.cxx index 2265ffd6aa84..8ffebc7cc27d 100644 --- a/svx/source/smarttags/SmartTagMgr.cxx +++ b/svx/source/smarttags/SmartTagMgr.cxx @@ -180,7 +180,7 @@ OUString SmartTagMgr::GetSmartTagCaption( const OUString& rSmartTagType, const c { OUString aRet; - auto aLower = maSmartTagMap.lower_bound( rSmartTagType ); + auto aLower = maSmartTagMap.find( rSmartTagType ); if ( aLower != maSmartTagMap.end() ) { diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx index 1cf88d394175..cd8ebb9b2a4b 100644 --- a/vcl/source/font/font.cxx +++ b/vcl/source/font/font.cxx @@ -610,9 +610,8 @@ namespace aEnt.string = pOpen+1; aEnt.string_len = (pClose-pOpen)-1; aEnt.weight = WEIGHT_NORMAL; - const int nEnt = SAL_N_ELEMENTS( weight_table ); - WeightSearchEntry const * pFound = std::lower_bound( weight_table, weight_table+nEnt, aEnt ); - if( pFound != (weight_table+nEnt) ) + WeightSearchEntry const * pFound = std::lower_bound( std::begin(weight_table), std::end(weight_table), aEnt ); + if( pFound != std::end(weight_table) && !(*pFound < aEnt)) o_rResult.SetWeight( pFound->weight ); } } diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx index 65a80932e90d..5410b652fbe3 100644 --- a/writerfilter/source/rtftok/rtftokenizer.cxx +++ b/writerfilter/source/rtftok/rtftokenizer.cxx @@ -247,10 +247,9 @@ bool RTFTokenizer::lookupMathKeyword(RTFMathSymbol& rSymbol) { auto low = std::lower_bound(s_aRTFMathControlWords.begin(), s_aRTFMathControlWords.end(), rSymbol); - int i = low - s_aRTFMathControlWords.begin(); if (low == s_aRTFMathControlWords.end() || rSymbol < *low) return false; - rSymbol = s_aRTFMathControlWords[i]; + rSymbol = *low; return true; } commit a3143aa0dec78177e522858fbf786494c75512a0 Author: Mike Kaganski <[email protected]> AuthorDate: Fri Oct 19 23:54:34 2018 +0200 Commit: Mike Kaganski <[email protected]> CommitDate: Sat Oct 20 08:00:23 2018 +0200 tdf#120703 (PVS): properly handle BSTR; fix enum comparison V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. V745 A 'wchar_t *' type string is incorrectly converted to 'BSTR' type string. Consider using 'SysAllocString' function. V768 The variable 'mnVersion' is of enum type. It is odd that it is used as a variable of a Boolean-type. Change-Id: If7533483a53467b6901d1f39411a634d77bbd840 Reviewed-on: https://gerrit.libreoffice.org/62033 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Mike Kaganski <[email protected]> diff --git a/extensions/source/activex/SOActiveX.cxx b/extensions/source/activex/SOActiveX.cxx index ee74dfdaa0fd..f13d58564bdc 100644 --- a/extensions/source/activex/SOActiveX.cxx +++ b/extensions/source/activex/SOActiveX.cxx @@ -354,18 +354,17 @@ STDMETHODIMP CSOActiveX::Load( LPPROPERTYBAG pPropBag, LPERRORLOG /*pErrorLog*/ return hr; } - USES_CONVERSION; for( unsigned long ind = 0; ind < aNum; ind++ ) { // all information from the 'object' tag is in strings - if( aVal[ind].vt == VT_BSTR && !strcmp( OLE2T( aPropNames[ind].pstrName ), "src" ) ) + if (aVal[ind].vt == VT_BSTR && !wcscmp(aPropNames[ind].pstrName, L"src")) { mCurFileUrl = wcsdup( aVal[ind].bstrVal ); } else if( aVal[ind].vt == VT_BSTR - && !strcmp( OLE2T( aPropNames[ind].pstrName ), "readonly" ) ) + && !wcscmp(aPropNames[ind].pstrName, L"readonly")) { - if( !strcmp( OLE2T( aVal[ind].bstrVal ), "true" ) ) + if (!wcscmp(aVal[ind].bstrVal, L"true")) { // the default value mbViewOnly = TRUE; @@ -385,9 +384,16 @@ STDMETHODIMP CSOActiveX::Load( LPPROPERTYBAG pPropBag, LPERRORLOG /*pErrorLog*/ return hr; mbReadyForActivation = FALSE; - hr = CBindStatusCallback<CSOActiveX>::Download( this, &CSOActiveX::CallbackCreateXInputStream, const_cast<OLECHAR *>(mCurFileUrl), m_spClientSite, FALSE ); - if ( hr == MK_S_ASYNCHRONOUS ) - hr = S_OK; + if (BSTR bStrUrl = SysAllocString(mCurFileUrl)) + { + hr = CBindStatusCallback<CSOActiveX>::Download( + this, &CSOActiveX::CallbackCreateXInputStream, bStrUrl, m_spClientSite, FALSE); + SysFreeString(bStrUrl); + if (hr == MK_S_ASYNCHRONOUS) + hr = S_OK; + } + else + hr = E_OUTOFMEMORY; if ( !SUCCEEDED( hr ) ) { @@ -912,23 +918,22 @@ SOVersion CSOActiveX::GetVersionConnected() if( SUCCEEDED( hr ) && aOfficeVersion.vt == VT_BSTR ) { - USES_CONVERSION; - if( !strcmp( OLE2T( aOfficeName.bstrVal ), "StarOffice" ) ) + if (!wcscmp(aOfficeName.bstrVal, L"StarOffice")) { - if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "6.1", 3 ) ) + if (!wcsncmp(aOfficeVersion.bstrVal, L"6.1", 3)) bResult = SO_61; - else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "6.0", 3 ) ) + else if (!wcsncmp(aOfficeVersion.bstrVal, L"6.0", 3)) bResult = SO_60; - else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "5.2", 3 ) ) + else if (!wcsncmp(aOfficeVersion.bstrVal, L"5.2", 3)) bResult = SO_52; else bResult = SO_UNKNOWN; } else // OpenOffice { - if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "1.1", 3 ) ) + if (!wcsncmp(aOfficeVersion.bstrVal, L"1.1", 3)) bResult = OO_11; - else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "1.0", 3 ) ) + else if (!wcsncmp(aOfficeVersion.bstrVal, L"1.0", 3)) bResult = OO_10; else bResult = OO_UNKNOWN; @@ -1030,7 +1035,7 @@ HRESULT CSOActiveX::OnDrawAdvanced( ATL_DRAWINFO& di ) } } - if( !mnVersion ) + if (mnVersion == SO_NOT_DETECTED) { OutputError_Impl( mOffWin, CS_E_INVALID_VERSION ); return E_FAIL; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
