diff --git a/mozilla/xpcom/string/src/nsStringObsolete.cpp b/mozilla/xpcom/string/src/nsStringObsolete.cpp index a3d55db8bf6..e6c6c849b20 100644 --- a/mozilla/xpcom/string/src/nsStringObsolete.cpp +++ b/mozilla/xpcom/string/src/nsStringObsolete.cpp @@ -780,7 +780,7 @@ RFindCharInSet( const CharT* data, PRUint32 dataLen, const SetCharT* set ) { CharT filter = nsBufferRoutines::get_find_in_set_filter(set); - for (const CharT* iter = data + dataLen; iter >= data; --iter) + for (const CharT* iter = data + dataLen - 1; iter >= data; --iter) { CharT currentChar = *iter; if (currentChar & filter) diff --git a/mozilla/xpcom/string/src/nsTStringObsolete.cpp b/mozilla/xpcom/string/src/nsTStringObsolete.cpp index 96d10d46f70..5ed065ad2e8 100644 --- a/mozilla/xpcom/string/src/nsTStringObsolete.cpp +++ b/mozilla/xpcom/string/src/nsTStringObsolete.cpp @@ -127,15 +127,13 @@ nsTString_CharT::FindCharInSet( const char* aSet, PRInt32 aOffset ) const PRInt32 nsTString_CharT::RFindCharInSet( const CharT* aSet, PRInt32 aOffset ) const { - if (aOffset < 0) - aOffset = 0; - else if (aOffset >= PRInt32(mLength)) - return kNotFound; - - PRInt32 result = ::RFindCharInSet(mData + aOffset, mLength - aOffset, aSet); - if (result != kNotFound) - result += aOffset; - return result; + // We want to pass a "data length" to ::RFindCharInSet + if (aOffset < 0 || aOffset > PRInt32(mLength)) + aOffset = mLength; + else + ++aOffset; + + return ::RFindCharInSet(mData, aOffset, aSet); }