From 69848d6b7cdb7b6df7e00efeca5ed01c08739ec5 Mon Sep 17 00:00:00 2001 From: "timeless@mozdev.org" Date: Thu, 15 Jan 2009 20:02:21 -0800 Subject: [PATCH] Bug 436925 - THREADSAFE nsCharsetConverterManager uses NS_CHARSETALIAS_CONTRACTID (nothreadsafe) from a random thread - triggered by Expired cert and nsDateTimeFormat, r=smontagu, sr=jst --- intl/uconv/src/nsCharsetConverterManager.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/intl/uconv/src/nsCharsetConverterManager.cpp b/intl/uconv/src/nsCharsetConverterManager.cpp index 5b2dc368abd9..685cb6356948 100644 --- a/intl/uconv/src/nsCharsetConverterManager.cpp +++ b/intl/uconv/src/nsCharsetConverterManager.cpp @@ -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 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);