Bug 334205: nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode returns unitialized value if outUnicodeLen = 0, r=timeless, sr=jag

This commit is contained in:
smontagu%smontagu.org 2006-05-07 09:06:58 +00:00
Родитель a0c06b2893
Коммит 669912aeaf
1 изменённых файлов: 4 добавлений и 8 удалений

Просмотреть файл

@ -156,19 +156,15 @@ nsPrimitiveHelpers :: ConvertUnicodeToPlatformPlainText ( PRUnichar* inUnicode,
if ( !outPlainTextData || !outPlainTextLen ) if ( !outPlainTextData || !outPlainTextLen )
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
// Get the appropriate unicode encoder. We're guaranteed that this won't change
// through the life of the app so we can cache it.
nsresult rv;
nsCOMPtr<nsIUnicodeEncoder> encoder;
// get the charset // get the charset
nsCAutoString platformCharset; nsresult rv;
nsCOMPtr <nsIPlatformCharset> platformCharsetService = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); nsCOMPtr <nsIPlatformCharset> platformCharsetService = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
nsCAutoString platformCharset;
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
rv = platformCharsetService->GetCharset(kPlatformCharsetSel_PlainTextInClipboard, platformCharset); rv = platformCharsetService->GetCharset(kPlatformCharsetSel_PlainTextInClipboard, platformCharset);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
platformCharset.AssignLiteral("ISO-8859-1"); platformCharset.AssignLiteral("ISO-8859-1");
// use transliterate to convert things like smart quotes to normal quotes for plain text // use transliterate to convert things like smart quotes to normal quotes for plain text
@ -207,7 +203,7 @@ nsPrimitiveHelpers :: ConvertPlatformPlainTextToUnicode ( const char* inText, PR
// Get the appropriate unicode decoder. We're guaranteed that this won't change // Get the appropriate unicode decoder. We're guaranteed that this won't change
// through the life of the app so we can cache it. // through the life of the app so we can cache it.
nsresult rv; nsresult rv = NS_OK;
static nsCOMPtr<nsIUnicodeDecoder> decoder; static nsCOMPtr<nsIUnicodeDecoder> decoder;
static PRBool hasConverter = PR_FALSE; static PRBool hasConverter = PR_FALSE;
if ( !hasConverter ) { if ( !hasConverter ) {