Kaydet (Commit) 35e80e97 authored tarafından Noel Grandin's avatar Noel Grandin

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: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst a3143aa0
......@@ -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;
}
};
}
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,
......
......@@ -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++;
......
......@@ -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() )
{
......
......@@ -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 );
}
}
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment