Fix crash due to unsigned integer underflow. b=100451 r=jag, harishd sr=waterson

git-svn-id: svn://10.0.0.236/trunk@103259 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dbaron%fas.harvard.edu 2001-09-20 02:15:21 +00:00
parent 3a5782e22d
commit 9dff5d268e
2 changed files with 10 additions and 6 deletions

View File

@ -1063,9 +1063,11 @@ static void DetermineHTMLParseMode(nsString& aBuffer,
publicID.ToLowerCase();
// binary search to see if we can find the correct public ID
PRUint32 minimum = 0;
PRUint32 maximum = ELEMENTS_OF(kPublicIDs) - 1;
PRUint32 index;
// These must be signed since maximum can go below zero and we'll
// crash if it's unsigned.
PRInt32 minimum = 0;
PRInt32 maximum = ELEMENTS_OF(kPublicIDs) - 1;
PRInt32 index;
for (;;) {
index = (minimum + maximum) / 2;
PRInt32 comparison =

View File

@ -1063,9 +1063,11 @@ static void DetermineHTMLParseMode(nsString& aBuffer,
publicID.ToLowerCase();
// binary search to see if we can find the correct public ID
PRUint32 minimum = 0;
PRUint32 maximum = ELEMENTS_OF(kPublicIDs) - 1;
PRUint32 index;
// These must be signed since maximum can go below zero and we'll
// crash if it's unsigned.
PRInt32 minimum = 0;
PRInt32 maximum = ELEMENTS_OF(kPublicIDs) - 1;
PRInt32 index;
for (;;) {
index = (minimum + maximum) / 2;
PRInt32 comparison =