make |Last| not try to adjust an iterator into an empty string (stops illegal calls to |Last| on an empty string from going into an infinite looop), r=mscott

git-svn-id: svn://10.0.0.236/trunk@77752 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scc%mozilla.org
2000-08-31 06:12:35 +00:00
parent abe39cdfa6
commit 9d68ddd2ce
3 changed files with 18 additions and 3 deletions

View File

@@ -571,7 +571,12 @@ basic_nsAReadableString<CharT>::Last() const
{
NS_ASSERTION(Length()>0, "|Last()| on an empty string");
return *(EndReading()-=1);
// nsReadingIterator<CharT> iter; EndReading(iter);
nsReadingIterator<CharT> iter( EndReading() );
if ( !IsEmpty() )
iter -= 1;
return *iter; // Note: this has undefined results if |IsEmpty()|
}
template <class CharT>