Bug 519337 - Don't read the sentinel value from a string. r=sicking
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 30 Sep 2009 15:15:51 -0700
changeset 33304 188996e474df4ae14ad61131b77a3ae6ff30c28b
parent 33303 cebf1a09f16843584953c6572ae5212eb0d50e5c
child 33305 70475458eabb6b54c966917bc1df9146e19e671b
push idunknown
push userunknown
push dateunknown
reviewerssicking
bugs519337
milestone1.9.3a1pre
Bug 519337 - Don't read the sentinel value from a string. r=sicking
parser/htmlparser/src/nsScanner.cpp
--- a/parser/htmlparser/src/nsScanner.cpp
+++ b/parser/htmlparser/src/nsScanner.cpp
@@ -1019,16 +1019,17 @@ nsresult nsScanner::ReadUntil(nsScannerI
   nsresult          result=Peek(theChar);
   
   if (NS_FAILED(result)) {
     aStart = aEnd = current;
     return result;
   }
   
   while (current != mEndPosition) {
+    theChar = *current;
     if (theChar == '\0') {
       ReplaceCharacter(current, sInvalid);
       theChar = sInvalid;
     }
 
     // Filter out completely wrong characters
     // Check if all bits are in the required area
     if(!(theChar & aEndCondition.mFilter)) {
@@ -1042,19 +1043,18 @@ nsresult nsScanner::ReadUntil(nsScannerI
           aEnd = current;
           SetPosition(current);
 
           return NS_OK;
         }
         ++setcurrent;
       }
     }
-    
+
     ++current;
-    theChar = *current;
   }
 
   // If we are here, we didn't find any terminator in the string and
   // current = mEndPosition
   SetPosition(current);
   aStart = origin;
   aEnd = current;
   return kEOF;
@@ -1083,30 +1083,30 @@ nsresult nsScanner::ReadUntil(nsAString&
   PRUnichar theChar;
   nsresult result = Peek(theChar);
 
   if (NS_FAILED(result)) {
     return result;
   }
 
   while (current != mEndPosition) {
+    theChar = *current;
     if (theChar == '\0') {
       ReplaceCharacter(current, sInvalid);
       theChar = sInvalid;
     }
 
     if (aTerminalChar == theChar) {
       if(addTerminal)
         ++current;
       AppendUnicodeTo(origin, current, aString);
       SetPosition(current);
       return NS_OK;
     }
     ++current;
-    theChar = *current;
   }
 
   // If we are here, we didn't find any terminator in the string and
   // current = mEndPosition
   AppendUnicodeTo(origin, current, aString);
   SetPosition(current);
   return kEOF;