Skip to content

Commit

Permalink
Ensure size of AA iterator does not change sign.
Browse files Browse the repository at this point in the history
  • Loading branch information
gfiumara committed Apr 14, 2021
1 parent 913bb54 commit e9c81f2
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/include/be_memory_autoarray.h
Expand Up @@ -690,7 +690,14 @@ template<class T>
typename BiometricEvaluation::Memory::AutoArray<T>::iterator
BiometricEvaluation::Memory::AutoArray<T>::end()
{
return (iterator(this, this->size()));
if (this->size() > std::numeric_limits<typename BiometricEvaluation::
Memory::AutoArrayIterator<false, T>::difference_type>::max())
throw BiometricEvaluation::Error::StrategyError{"AutoArray too "
"large to represent end iterator"};

return (iterator(this,
static_cast<typename BiometricEvaluation::Memory::
AutoArrayIterator<false, T>::difference_type>(this->size())));
}

template<class T>
Expand All @@ -706,7 +713,14 @@ typename BiometricEvaluation::Memory::AutoArray<T>::const_iterator
BiometricEvaluation::Memory::AutoArray<T>::cend()
const
{
return (const_iterator(this, this->size()));
if (this->size() > std::numeric_limits<typename BiometricEvaluation::
Memory::AutoArrayIterator<true, T>::difference_type>::max())
throw BiometricEvaluation::Error::StrategyError{"AutoArray too "
"large to represent end iterator"};

return (const_iterator(this,
static_cast<typename BiometricEvaluation::Memory::
AutoArrayIterator<true, T>::difference_type>(this->size())));
}

/******************************************************************************/
Expand Down

0 comments on commit e9c81f2

Please sign in to comment.