Bug 1336836 - Null-check mEncoder for XPCOM shutdown. r=emk a=gchang
authorHenri Sivonen <hsivonen@hsivonen.fi>
Thu, 16 Feb 2017 08:40:30 +0200
changeset 376298 661e35b83224d2962961d955c834d4c08ce8320d
parent 376297 a4dd9746a71219c06fb2b178c4938d90f1ac4317
child 376299 a6d3ee554e58f1439e0111da53753d37433c7ccc
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk, gchang
bugs1336836
milestone53.0a2
Bug 1336836 - Null-check mEncoder for XPCOM shutdown. r=emk a=gchang MozReview-Commit-ID: G6UeBdUbK85
intl/uconv/nsNCRFallbackEncoderWrapper.cpp
--- a/intl/uconv/nsNCRFallbackEncoderWrapper.cpp
+++ b/intl/uconv/nsNCRFallbackEncoderWrapper.cpp
@@ -41,16 +41,20 @@ nsNCRFallbackEncoderWrapper::WriteNCR(ns
   aDstWritten += ncrLen;
   return true;
 }
 
 bool
 nsNCRFallbackEncoderWrapper::Encode(const nsAString& aUtf16,
                                     nsACString& aBytes)
 {
+  // mozilla::dom::EncodingUtils::EncoderForEncoding fails during shutdown
+  if (!mEncoder) {
+    return false;
+  }
   // nsIUnicodeEncoder uses int32_t for sizes :-(
   if (aUtf16.Length() > INT32_MAX) {
     return false;
   }
   const char16_t* src = aUtf16.BeginReading();
   const char16_t* srcEnd = aUtf16.EndReading();
   uint32_t dstWritten = 0;
   for (;;) {