#122081 Universalchardet leaks memory

The fix for the nsCharSetProber class declaration, plus fix for
nsUniversalDetector methods, which may cause another leak when the object is
reused after Reset().

Patch proposed by Takayuki Tamura
r=shanjian, sr/a=brendan
This commit is contained in:
shanjian%netscape.com 2005-11-02 16:57:03 +00:00
parent 81c3bb18d5
commit 2c8314b3ba
2 changed files with 4 additions and 2 deletions

View File

@ -50,6 +50,7 @@ typedef enum {
class nsCharSetProber {
public:
virtual ~nsCharSetProber() {};
virtual const char* GetCharSetName() = 0;
virtual nsProbingState HandleData(const char* aBuf, PRUint32 aLen) = 0;
virtual nsProbingState GetState(void) = 0;

View File

@ -89,7 +89,6 @@ nsUniversalDetector::Reset()
mDone = PR_FALSE;
mBestGuess = -1; //illegal value as signal
mInTag = PR_FALSE;
mEscCharSetProber = nsnull;
mStart = PR_TRUE;
mDetectedCharset = nsnull;
@ -148,8 +147,10 @@ void nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen)
mInputState = eHighbyte;
//kill mEscCharSetProber if it is active
if (mEscCharSetProber)
if (mEscCharSetProber) {
delete mEscCharSetProber;
mEscCharSetProber = nsnull;
}
//start multibyte and singlebyte charset prober
if (nsnull == mCharSetProbers[0])