Skip to content

Commit

Permalink
Bug 244177: nsScanner::Append() can overwrite the storage in the buff…
Browse files Browse the repository at this point in the history
…er it allocates. r=dveditz, sr=dbaron.
  • Loading branch information
smontagu%smontagu.org committed Oct 27, 2004
1 parent aa1fa55 commit a249255
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions parser/htmlparser/src/nsScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,15 @@ nsresult nsScanner::Append(const char* aBuffer, PRUint32 aLen){
if(NS_FAILED(res)) {
// if we failed, we consume one byte, replace it with U+FFFD
// and try the conversion again.

// This is only needed because some decoders don't follow the
// nsIUnicodeDecoder contract: they return a failure when *aDestLength
// is 0 rather than the correct NS_OK_UDEC_MOREOUTPUT. See bug 244177
if ((unichars + unicharLength) >= buffer->DataEnd()) {
NS_ERROR("Unexpected end of destination buffer");
break;
}

unichars[unicharLength++] = (PRUnichar)0xFFFD;
unichars = unichars + unicharLength;
unicharLength = unicharBufLen - (++totalChars);
Expand Down

0 comments on commit a249255

Please sign in to comment.