From 69ac84dbd0950d8cd54a5fe9b05ed23297e572bf Mon Sep 17 00:00:00 2001 From: "jaggernaut%netscape.com" Date: Fri, 1 Feb 2002 14:22:22 +0000 Subject: [PATCH] Bug 122083: Typing "v", "vi", "vie" ... "view-source" into URL bar and pressing enter freezes Mozilla. r=dbradley, sr=alecf git-svn-id: svn://10.0.0.236/trunk@113414 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/string/obsolete/nsStr.cpp | 12 ++++++++---- mozilla/xpcom/string/obsolete/nsStr.cpp | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/mozilla/string/obsolete/nsStr.cpp b/mozilla/string/obsolete/nsStr.cpp index 66720179777..4acc9ab610d 100644 --- a/mozilla/string/obsolete/nsStr.cpp +++ b/mozilla/string/obsolete/nsStr.cpp @@ -1112,10 +1112,14 @@ static inline PRInt32 TranslateCompareResult(const PRInt32 aDestLength, const PRInt32& aSourceLength, PRInt32 result, PRInt32 aCount) { - if (0==result && -1==aCount) { - //Since the caller didn't give us a length to test, and minlen characters matched, - //we have to assume that the longer string is greater. - + if (0==result && (-1==aCount || + aDestLength < aCount || + aSourceLength < aCount)) { + + //Since the caller didn't give us a length to test, or strings shorter + //than aCount, and minlen characters matched, we have to assume that the + //longer string is greater. + if (aDestLength != aSourceLength) { //we think they match, but we've only compared minlen characters. //if the string lengths are different, then they don't really match. diff --git a/mozilla/xpcom/string/obsolete/nsStr.cpp b/mozilla/xpcom/string/obsolete/nsStr.cpp index 66720179777..4acc9ab610d 100644 --- a/mozilla/xpcom/string/obsolete/nsStr.cpp +++ b/mozilla/xpcom/string/obsolete/nsStr.cpp @@ -1112,10 +1112,14 @@ static inline PRInt32 TranslateCompareResult(const PRInt32 aDestLength, const PRInt32& aSourceLength, PRInt32 result, PRInt32 aCount) { - if (0==result && -1==aCount) { - //Since the caller didn't give us a length to test, and minlen characters matched, - //we have to assume that the longer string is greater. - + if (0==result && (-1==aCount || + aDestLength < aCount || + aSourceLength < aCount)) { + + //Since the caller didn't give us a length to test, or strings shorter + //than aCount, and minlen characters matched, we have to assume that the + //longer string is greater. + if (aDestLength != aSourceLength) { //we think they match, but we've only compared minlen characters. //if the string lengths are different, then they don't really match.