Bug 66786, fix UMR in GetLine(). Fix by Daniel Bratell (bratell@lysator.liu.se). r=heikki, sr=vidur.

This commit is contained in:
heikki%netscape.com 2001-03-07 02:03:57 +00:00
parent a4551b8ee8
commit a8ee517153
2 changed files with 8 additions and 8 deletions
htmlparser/src
parser/htmlparser/src

@ -254,18 +254,18 @@ void nsExpatTokenizer::GetLine(const char* aSourceBuffer, PRUint32 aLength,
/* Use start to find the first new line before the error position and
end to find the first new line after the error position */
reachedStart = ('\n' == *start || '\r' == *start || startIndex <= 0);
reachedEnd = ('\n' == *end || '\r' == *end || endIndex >= numCharsInBuffer);
reachedStart = (startIndex <= 0 || '\n' == *start || '\r' == *start);
reachedEnd = (endIndex >= numCharsInBuffer || '\n' == *end || '\r' == *end);
while (!reachedStart || !reachedEnd) {
if (!reachedStart) {
start--;
startIndex--;
reachedStart = ('\n' == *start || '\r' == *start || startIndex <= 0);
reachedStart = (startIndex <= 0 || '\n' == *start || '\r' == *start);
}
if (!reachedEnd) {
end++;
endIndex++;
reachedEnd = ('\n' == *end || '\r' == *end || endIndex >= numCharsInBuffer);
reachedEnd = (endIndex >= numCharsInBuffer || '\n' == *end || '\r' == *end);
}
}

@ -254,18 +254,18 @@ void nsExpatTokenizer::GetLine(const char* aSourceBuffer, PRUint32 aLength,
/* Use start to find the first new line before the error position and
end to find the first new line after the error position */
reachedStart = ('\n' == *start || '\r' == *start || startIndex <= 0);
reachedEnd = ('\n' == *end || '\r' == *end || endIndex >= numCharsInBuffer);
reachedStart = (startIndex <= 0 || '\n' == *start || '\r' == *start);
reachedEnd = (endIndex >= numCharsInBuffer || '\n' == *end || '\r' == *end);
while (!reachedStart || !reachedEnd) {
if (!reachedStart) {
start--;
startIndex--;
reachedStart = ('\n' == *start || '\r' == *start || startIndex <= 0);
reachedStart = (startIndex <= 0 || '\n' == *start || '\r' == *start);
}
if (!reachedEnd) {
end++;
endIndex++;
reachedEnd = ('\n' == *end || '\r' == *end || endIndex >= numCharsInBuffer);
reachedEnd = (endIndex >= numCharsInBuffer || '\n' == *end || '\r' == *end);
}
}