summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-19 16:01:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-20 08:00:32 +0200
commit35e80e9726b5fee6a00caa58349a4b5d924dad7c (patch)
tree3f92cdee5079affdc40b73f26845d73e9a994412
parenta3143aa0dec78177e522858fbf786494c75512a0 (diff)
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 <noel.grandin@collabora.co.uk>
-rw-r--r--basic/source/classes/propacc.cxx13
-rw-r--r--comphelper/source/property/propagg.cxx2
-rw-r--r--svx/source/smarttags/SmartTagMgr.cxx2
-rw-r--r--vcl/source/font/font.cxx5
-rw-r--r--writerfilter/source/rtftok/rtftokenizer.cxx3
5 files changed, 10 insertions, 15 deletions
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;
}