mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-25 06:10:35 +00:00
Fixed wrong inputs for charset converter Finish() call, bug 33588, r=cata.
This commit is contained in:
parent
f2d22e0d0a
commit
b28517a966
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user