diff --git a/xpcom/glue/nsStringAPI.h b/xpcom/glue/nsStringAPI.h index 8f88125cfb9..d9202d7bd0b 100644 --- a/xpcom/glue/nsStringAPI.h +++ b/xpcom/glue/nsStringAPI.h @@ -1322,7 +1322,8 @@ Substring( const nsAString& str, PRUint32 startPos, PRUint32 length ) inline const nsDependentSubstring Substring( const PRUnichar* start, const PRUnichar* end ) { - return nsDependentSubstring(start, end - start); + NS_ABORT_IF_FALSE(PRUint32(end - start) == end - start, "string too long"); + return nsDependentSubstring(start, PRUint32(end - start)); } inline const nsDependentSubstring @@ -1360,7 +1361,8 @@ inline const nsDependentCSubstring Substring( const char* start, const char* end ) { - return nsDependentCSubstring(start, end - start); + NS_ABORT_IF_FALSE(PRUint32(end - start) == end - start, "string too long"); + return nsDependentCSubstring(start, PRUint32(end - start)); } inline