Fixed wrong inputs for charset converter Finish() call, bug 33588, r=cata.

This commit is contained in:
nhotta%netscape.com 2000-03-29 23:16:55 +00:00
parent f2d22e0d0a
commit b28517a966
2 changed files with 5 additions and 3 deletions

View File

@ -108,10 +108,11 @@ nsresult ConvertFromUnicode(const nsString& aCharset,
// allocale an output buffer
*outCString = (char *) PR_Malloc(dstLength + 1);
if (nsnull != *outCString) {
PRInt32 buffLength = dstLength;
**outCString = '\0';
res = encoder->Convert(unichars, &unicharLength, *outCString, &dstLength);
if (NS_SUCCEEDED(res)) {
PRInt32 finLen;
PRInt32 finLen = buffLength - dstLength;
res = encoder->Finish((char *)(*outCString+dstLength), &finLen);
if (NS_SUCCEEDED(res)) {
dstLength += finLen;

View File

@ -1415,13 +1415,14 @@ PRInt32 MimeCharsetConverterClass::Convert(const char* inBuffer, const PRInt32 i
res = NS_ERROR_OUT_OF_MEMORY;
}
else {
PRInt32 buffLength = dstLength;
// convert from unicode
res = encoder->SetOutputErrorBehavior(nsIUnicodeEncoder::kOnError_Replace, nsnull, '?');
if (NS_SUCCEEDED(res)) {
res = encoder->Convert(unichars, &unicharLength, dstPtr, &dstLength);
if (NS_SUCCEEDED(res)) {
PRInt32 finLen;
res = encoder->Finish((char *)(*dstPtr+dstLength), &finLen);
PRInt32 finLen = buffLength - dstLength;
res = encoder->Finish((char *)(dstPtr+dstLength), &finLen);
if (NS_SUCCEEDED(res)) {
dstLength += finLen;
}