Skip to content
Snippets Groups Projects
Commit 54cc8b27 authored by Oliver Sander's avatar Oliver Sander Committed by Markus Blatt
Browse files

Do not crash in find() if array is empty

This fixes FS 1292, but with my own slightly different patch.
parent fe444d37
No related branches found
No related tags found
No related merge requests found
......@@ -716,6 +716,9 @@ namespace Dune {
//! random access returning iterator (end if not contained)
iterator find (size_type i)
{
if (n==0)
return end();
size_type l=0, r=n-1;
while (l<r)
{
......@@ -724,7 +727,7 @@ namespace Dune {
else l = q+1;
}
if (n && i==j[l])
if (i==j[l])
return iterator(p,j,l);
else
return iterator(p,j,n);
......@@ -762,6 +765,9 @@ namespace Dune {
//! random access returning iterator (end if not contained)
const_iterator find (size_type i) const
{
if (n==0)
return end();
size_type l=0, r=n-1;
while (l<r)
{
......@@ -770,7 +776,7 @@ namespace Dune {
else l = q+1;
}
if (n && i==j[l])
if (i==j[l])
return const_iterator(p,j,l);
else
return const_iterator(p,j,n);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment