diff --git a/mozilla/string/public/nsAReadableString.h b/mozilla/string/public/nsAReadableString.h index f0862e8db6a..888574e0d5d 100644 --- a/mozilla/string/public/nsAReadableString.h +++ b/mozilla/string/public/nsAReadableString.h @@ -571,7 +571,12 @@ basic_nsAReadableString::Last() const { NS_ASSERTION(Length()>0, "|Last()| on an empty string"); - return *(EndReading()-=1); + // nsReadingIterator iter; EndReading(iter); + nsReadingIterator iter( EndReading() ); + if ( !IsEmpty() ) + iter -= 1; + + return *iter; // Note: this has undefined results if |IsEmpty()| } template diff --git a/mozilla/xpcom/ds/nsAReadableString.h b/mozilla/xpcom/ds/nsAReadableString.h index f0862e8db6a..888574e0d5d 100644 --- a/mozilla/xpcom/ds/nsAReadableString.h +++ b/mozilla/xpcom/ds/nsAReadableString.h @@ -571,7 +571,12 @@ basic_nsAReadableString::Last() const { NS_ASSERTION(Length()>0, "|Last()| on an empty string"); - return *(EndReading()-=1); + // nsReadingIterator iter; EndReading(iter); + nsReadingIterator iter( EndReading() ); + if ( !IsEmpty() ) + iter -= 1; + + return *iter; // Note: this has undefined results if |IsEmpty()| } template diff --git a/mozilla/xpcom/string/public/nsAReadableString.h b/mozilla/xpcom/string/public/nsAReadableString.h index f0862e8db6a..888574e0d5d 100644 --- a/mozilla/xpcom/string/public/nsAReadableString.h +++ b/mozilla/xpcom/string/public/nsAReadableString.h @@ -571,7 +571,12 @@ basic_nsAReadableString::Last() const { NS_ASSERTION(Length()>0, "|Last()| on an empty string"); - return *(EndReading()-=1); + // nsReadingIterator iter; EndReading(iter); + nsReadingIterator iter( EndReading() ); + if ( !IsEmpty() ) + iter -= 1; + + return *iter; // Note: this has undefined results if |IsEmpty()| } template