From eb2533ba2da2fd9579ac963991dcf77313e4bdd9 Mon Sep 17 00:00:00 2001 From: "ftang%netscape.com" Date: Wed, 5 May 1999 23:53:49 +0000 Subject: [PATCH] fix signed/unsigned problem, call Reset function when error occur git-svn-id: svn://10.0.0.236/trunk@30449 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/htmlparser/src/nsScanner.cpp | 9 +++++++-- mozilla/parser/htmlparser/src/nsScanner.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mozilla/htmlparser/src/nsScanner.cpp b/mozilla/htmlparser/src/nsScanner.cpp index a9b9adf7d85..a9df64adc95 100644 --- a/mozilla/htmlparser/src/nsScanner.cpp +++ b/mozilla/htmlparser/src/nsScanner.cpp @@ -257,10 +257,15 @@ PRBool nsScanner::Append(const char* aBuffer, PRUint32 aLen){ // if we failed, we consume one byte by replace it with U+FFFD // and try conversion again. if(NS_FAILED(res)) { + mUnicodeDecoder->Reset(); mBuffer.Append( (PRUnichar)0xFFFD); mTotalRead++; - aBuffer += srcLength + 1; - aLen -= srcLength + 1; + if(((PRUint32) (srcLength + 1)) > aLen) + srcLength = aLen; + else + srcLength++; + aBuffer += srcLength; + aLen -= srcLength; } } while (NS_FAILED(res) && (aLen > 0)); // we continue convert the bytes data into Unicode diff --git a/mozilla/parser/htmlparser/src/nsScanner.cpp b/mozilla/parser/htmlparser/src/nsScanner.cpp index a9b9adf7d85..a9df64adc95 100644 --- a/mozilla/parser/htmlparser/src/nsScanner.cpp +++ b/mozilla/parser/htmlparser/src/nsScanner.cpp @@ -257,10 +257,15 @@ PRBool nsScanner::Append(const char* aBuffer, PRUint32 aLen){ // if we failed, we consume one byte by replace it with U+FFFD // and try conversion again. if(NS_FAILED(res)) { + mUnicodeDecoder->Reset(); mBuffer.Append( (PRUnichar)0xFFFD); mTotalRead++; - aBuffer += srcLength + 1; - aLen -= srcLength + 1; + if(((PRUint32) (srcLength + 1)) > aLen) + srcLength = aLen; + else + srcLength++; + aBuffer += srcLength; + aLen -= srcLength; } } while (NS_FAILED(res) && (aLen > 0)); // we continue convert the bytes data into Unicode