Bug 436925 - THREADSAFE nsCharsetConverterManager uses NS_CHARSETALIAS_CONTRACTID (nothreadsafe) from a random thread - triggered by Expired cert and nsDateTimeFormat, r=smontagu, sr=jst

This commit is contained in:
timeless@mozdev.org 2009-01-15 20:02:21 -08:00
parent ba41e71939
commit f8f56e3b92

View File

@ -52,6 +52,8 @@
#include "nsCRT.h"
#include "nsVoidArray.h"
#include "nsStringEnumerator.h"
#include "nsThreadUtils.h"
#include "nsIProxyObjectManager.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
@ -370,6 +372,18 @@ nsCharsetConverterManager::GetCharsetAlias(const char * aCharset,
if (!aCharset)
return NS_ERROR_NULL_POINTER;
// We must not use the charset alias from a background thread
if (!NS_IsMainThread()) {
nsCOMPtr<nsICharsetConverterManager> self;
nsresult rv =
NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
NS_GET_IID(nsICharsetConverterManager),
this, NS_PROXY_SYNC | NS_PROXY_ALWAYS,
getter_AddRefs(self));
NS_ENSURE_SUCCESS(rv, rv);
return self->GetCharsetAlias(aCharset, aResult);
}
// We try to obtain the preferred name for this charset from the charset
// aliases. If we don't get it from there, we just use the original string
nsDependentCString charset(aCharset);