Backed out changeset 3d0093f961ee (bug 1410794) for Mac plugin crashes and Android test_worker_interfaces.html failures
authorPhil Ringnalda <philringnalda@gmail.com>
Tue, 24 Oct 2017 22:46:36 -0700
changeset 438879 23f3b04d3e1383dd5c4cef2cd3ff3c0db2348d4f
parent 438878 f642827358b4b2109ff05b564744b616f7cc7a91
child 438880 7ec816bf52c45e234bbd6339a9c7d5985668632d
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1410794
milestone58.0a1
backs out3d0093f961eec929caa370444cd0f7fcbfbc82bc
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 3d0093f961ee (bug 1410794) for Mac plugin crashes and Android test_worker_interfaces.html failures MozReview-Commit-ID: 20UosHyIr0t
browser/components/dirprovider/DirectoryProvider.cpp
chrome/nsChromeRegistryChrome.cpp
extensions/auth/nsAuthGSSAPI.cpp
extensions/pref/autoconfig/src/nsAutoConfig.cpp
extensions/pref/autoconfig/src/nsReadConfig.cpp
extensions/spellcheck/hunspell/glue/mozHunspell.cpp
media/mtransport/nricectx.cpp
modules/libpref/Preferences.cpp
modules/libpref/nsIPrefBranch.idl
netwerk/base/nsIOService.cpp
netwerk/base/nsProtocolProxyService.cpp
netwerk/dns/nsDNSService2.cpp
netwerk/dns/nsIDNService.cpp
netwerk/protocol/ftp/nsFtpConnectionThread.cpp
netwerk/protocol/gio/nsGIOProtocolHandler.cpp
netwerk/protocol/http/HttpAuthUtils.cpp
netwerk/protocol/http/nsHttpHandler.cpp
toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
toolkit/components/url-classifier/nsUrlClassifierUtils.cpp
toolkit/xre/nsAppRunner.cpp
--- a/browser/components/dirprovider/DirectoryProvider.cpp
+++ b/browser/components/dirprovider/DirectoryProvider.cpp
@@ -104,19 +104,19 @@ AppendDistroSearchDirs(nsIProperties* aD
 
     nsCOMPtr<nsIFile> localePlugins;
     rv = searchPlugins->Clone(getter_AddRefs(localePlugins));
     if (NS_FAILED(rv))
       return;
 
     localePlugins->AppendNative(NS_LITERAL_CSTRING("locale"));
 
-    nsAutoCString defLocale;
+    nsCString defLocale;
     rv = prefs->GetCharPref("distribution.searchplugins.defaultLocale",
-                            defLocale);
+                            getter_Copies(defLocale));
     if (NS_SUCCEEDED(rv)) {
 
       nsCOMPtr<nsIFile> defLocalePlugins;
       rv = localePlugins->Clone(getter_AddRefs(defLocalePlugins));
       if (NS_SUCCEEDED(rv)) {
 
         defLocalePlugins->AppendNative(defLocale);
         rv = defLocalePlugins->Exists(&exists);
--- a/chrome/nsChromeRegistryChrome.cpp
+++ b/chrome/nsChromeRegistryChrome.cpp
@@ -123,18 +123,18 @@ nsChromeRegistryChrome::Init()
     } else {
       prefs = do_QueryInterface(prefserv);
     }
   }
 
   if (!prefs) {
     NS_WARNING("Could not get pref service!");
   } else {
-    nsAutoCString provider;
-    rv = prefs->GetCharPref(SELECTED_SKIN_PREF, provider);
+    nsCString provider;
+    rv = prefs->GetCharPref(SELECTED_SKIN_PREF, getter_Copies(provider));
     if (NS_SUCCEEDED(rv))
       mSelectedSkin = provider;
 
     rv = prefs->AddObserver(SELECTED_SKIN_PREF, this, true);
   }
 
   nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService();
   if (obsService) {
@@ -270,18 +270,18 @@ nsChromeRegistryChrome::Observe(nsISuppo
 
   if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic)) {
     nsCOMPtr<nsIPrefBranch> prefs (do_QueryInterface(aSubject));
     NS_ASSERTION(prefs, "Bad observer call!");
 
     NS_ConvertUTF16toUTF8 pref(someData);
 
     if (pref.EqualsLiteral(SELECTED_SKIN_PREF)) {
-      nsAutoCString provider;
-      rv = prefs->GetCharPref(pref.get(), provider);
+      nsCString provider;
+      rv = prefs->GetCharPref(pref.get(), getter_Copies(provider));
       if (NS_FAILED(rv)) {
         NS_ERROR("Couldn't get new skin pref!");
         return rv;
       }
 
       mSelectedSkin = provider;
       RefreshSkins();
     } else {
--- a/extensions/auth/nsAuthGSSAPI.cpp
+++ b/extensions/auth/nsAuthGSSAPI.cpp
@@ -97,20 +97,20 @@ static PRLibrary* gssLibrary = nullptr;
 static PRFuncPtr KLCacheHasValidTicketsPtr;
 #define KLCacheHasValidTickets_ptr \
         ((KLCacheHasValidTickets_type)*KLCacheHasValidTicketsPtr)
 #endif
 
 static nsresult
 gssInit()
 {
-    nsAutoCString libPath;
+    nsCString libPath;
     nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
     if (prefs) {
-        prefs->GetCharPref(kNegotiateAuthGssLib, libPath);
+        prefs->GetCharPref(kNegotiateAuthGssLib, getter_Copies(libPath));
         prefs->GetBoolPref(kNegotiateAuthNativeImp, &gssNativeImp);
     }
 
     PRLibrary *lib = nullptr;
 
     if (!libPath.IsEmpty()) {
         LOG(("Attempting to load user specified library [%s]\n", libPath.get()));
         gssNativeImp = false;
--- a/extensions/pref/autoconfig/src/nsAutoConfig.cpp
+++ b/extensions/pref/autoconfig/src/nsAutoConfig.cpp
@@ -453,48 +453,49 @@ nsresult nsAutoConfig::writeFailoverFile
     outStr->Close();
     return rv;
 }
 
 nsresult nsAutoConfig::getEmailAddr(nsACString & emailAddr)
 {
 
     nsresult rv;
-    nsAutoCString prefValue;
+    nsCString prefValue;
 
     /* Getting an email address through set of three preferences:
        First getting a default account with
        "mail.accountmanager.defaultaccount"
        second getting an associated id with the default account
        Third getting an email address with id
     */
 
     rv = mPrefBranch->GetCharPref("mail.accountmanager.defaultaccount",
-                                  prefValue);
+                                  getter_Copies(prefValue));
     if (NS_SUCCEEDED(rv) && !prefValue.IsEmpty()) {
         emailAddr = NS_LITERAL_CSTRING("mail.account.") +
             prefValue + NS_LITERAL_CSTRING(".identities");
         rv = mPrefBranch->GetCharPref(PromiseFlatCString(emailAddr).get(),
-                                      prefValue);
+                                      getter_Copies(prefValue));
         if (NS_FAILED(rv) || prefValue.IsEmpty())
             return PromptForEMailAddress(emailAddr);
         int32_t commandIndex = prefValue.FindChar(',');
         if (commandIndex != kNotFound)
           prefValue.Truncate(commandIndex);
         emailAddr = NS_LITERAL_CSTRING("mail.identity.") +
             prefValue + NS_LITERAL_CSTRING(".useremail");
         rv = mPrefBranch->GetCharPref(PromiseFlatCString(emailAddr).get(),
-                                      prefValue);
+                                      getter_Copies(prefValue));
         if (NS_FAILED(rv)  || prefValue.IsEmpty())
             return PromptForEMailAddress(emailAddr);
         emailAddr = prefValue;
     }
     else {
         // look for 4.x pref in case we just migrated.
-        rv = mPrefBranch->GetCharPref("mail.identity.useremail", prefValue);
+        rv = mPrefBranch->GetCharPref("mail.identity.useremail",
+                                  getter_Copies(prefValue));
         if (NS_SUCCEEDED(rv) && !prefValue.IsEmpty())
             emailAddr = prefValue;
         else
             PromptForEMailAddress(emailAddr);
     }
 
     return NS_OK;
 }
--- a/extensions/pref/autoconfig/src/nsReadConfig.cpp
+++ b/extensions/pref/autoconfig/src/nsReadConfig.cpp
@@ -110,35 +110,35 @@ NS_IMETHODIMP nsReadConfig::Observe(nsIS
     }
     return rv;
 }
 
 
 nsresult nsReadConfig::readConfigFile()
 {
     nsresult rv = NS_OK;
-    nsAutoCString lockFileName;
-    nsAutoCString lockVendor;
+    nsCString lockFileName;
+    nsCString lockVendor;
     uint32_t fileNameLen = 0;
 
     nsCOMPtr<nsIPrefBranch> defaultPrefBranch;
     nsCOMPtr<nsIPrefService> prefService =
         do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
     if (NS_FAILED(rv))
         return rv;
 
     rv = prefService->GetDefaultBranch(nullptr, getter_AddRefs(defaultPrefBranch));
     if (NS_FAILED(rv))
         return rv;
 
     // This preference is set in the all.js or all-ns.js (depending whether
     // running mozilla or netscp6)
 
     rv = defaultPrefBranch->GetCharPref("general.config.filename",
-                                        lockFileName);
+                                  getter_Copies(lockFileName));
 
 
     MOZ_LOG(MCD, LogLevel::Debug, ("general.config.filename = %s\n", lockFileName.get()));
     if (NS_FAILED(rv))
         return rv;
 
     // This needs to be read only once.
     //
@@ -174,40 +174,43 @@ nsresult nsReadConfig::readConfigFile()
     rv = openAndEvaluateJSFile(lockFileName.get(), obscureValue, true, true);
     if (NS_FAILED(rv))
     {
       MOZ_LOG(MCD, LogLevel::Debug, ("error evaluating .cfg file %s %" PRIx32 "\n",
                                      lockFileName.get(), static_cast<uint32_t>(rv)));
       return rv;
     }
 
-    rv = prefBranch->GetCharPref("general.config.filename", lockFileName);
+    rv = prefBranch->GetCharPref("general.config.filename",
+                                  getter_Copies(lockFileName));
     if (NS_FAILED(rv))
         // There is NO REASON we should ever get here. This is POST reading
         // of the config file.
         return NS_ERROR_FAILURE;
 
 
-    rv = prefBranch->GetCharPref("general.config.vendor", lockVendor);
+    rv = prefBranch->GetCharPref("general.config.vendor",
+                                  getter_Copies(lockVendor));
     // If vendor is not nullptr, do this check
     if (NS_SUCCEEDED(rv)) {
 
         fileNameLen = strlen(lockFileName.get());
 
         // lockVendor and lockFileName should be the same with the addtion of
         // .cfg to the filename by checking this post reading of the cfg file
         // this value can be set within the cfg file adding a level of security.
 
         if (PL_strncmp(lockFileName.get(), lockVendor.get(), fileNameLen - 4) != 0)
             return NS_ERROR_FAILURE;
     }
 
     // get the value of the autoconfig url
-    nsAutoCString urlName;
-    rv = prefBranch->GetCharPref("autoadmin.global_config_url", urlName);
+    nsCString urlName;
+    rv = prefBranch->GetCharPref("autoadmin.global_config_url",
+                                  getter_Copies(urlName));
     if (NS_SUCCEEDED(rv) && !urlName.IsEmpty()) {
 
         // Instantiating nsAutoConfig object if the pref is present
         mAutoConfig = do_CreateInstance(NS_AUTOCONFIG_CONTRACTID, &rv);
         if (NS_FAILED(rv))
             return NS_ERROR_OUT_OF_MEMORY;
 
         rv = mAutoConfig->SetConfigURL(urlName.get());
--- a/extensions/spellcheck/hunspell/glue/mozHunspell.cpp
+++ b/extensions/spellcheck/hunspell/glue/mozHunspell.cpp
@@ -309,18 +309,18 @@ mozHunspell::LoadDictionaryList(bool aNo
 
   // find built in dictionaries, or dictionaries specified in
   // spellchecker.dictionary_path in prefs
   nsCOMPtr<nsIFile> dictDir;
 
   // check preferences first
   nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
   if (prefs) {
-    nsAutoCString extDictPath;
-    rv = prefs->GetCharPref("spellchecker.dictionary_path", extDictPath);
+    nsCString extDictPath;
+    rv = prefs->GetCharPref("spellchecker.dictionary_path", getter_Copies(extDictPath));
     if (NS_SUCCEEDED(rv)) {
       // set the spellchecker.dictionary_path
       rv = NS_NewNativeLocalFile(extDictPath, true, getter_AddRefs(dictDir));
     }
   }
   if (!dictDir) {
     // spellcheck.dictionary_path not found, set internal path
     rv = dirSvc->Get(DICTIONARY_SEARCH_DIRECTORY,
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -452,17 +452,17 @@ NrIceCtx::InitializeGlobals(bool allow_l
         branch->GetIntPref(
             "media.peerconnection.ice.tcp_so_sock_count",
             &ice_tcp_so_sock_count);
         branch->GetIntPref(
             "media.peerconnection.ice.tcp_listen_backlog",
             &ice_tcp_listen_backlog);
         branch->GetCharPref(
             "media.peerconnection.ice.force_interface",
-            force_net_interface);
+            getter_Copies(force_net_interface));
       }
     }
 
     NR_reg_set_uint4((char *)"stun.client.maximum_transmits",
                      stun_client_maximum_transmits);
     NR_reg_set_uint4((char *)NR_ICE_REG_TRICKLE_GRACE_PERIOD,
                      ice_trickle_grace_period);
     NR_reg_set_int4((char *)NR_ICE_REG_ICE_TCP_SO_SOCK_COUNT,
@@ -628,35 +628,35 @@ NrIceCtx::Initialize(const std::string& 
   if (generating_trickle()) {
     r = nr_ice_ctx_set_trickle_cb(ctx_, &NrIceCtx::trickle_cb, this);
     if (r) {
       MOZ_MTLOG(ML_ERROR, "Couldn't set trickle cb for '" << name_ << "'");
       return false;
     }
   }
 
-  nsAutoCString mapping_type;
-  nsAutoCString filtering_type;
+  nsCString mapping_type;
+  nsCString filtering_type;
   bool block_udp = false;
   bool block_tcp = false;
 
   nsresult rv;
   nsCOMPtr<nsIPrefService> pref_service =
     do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
 
   if (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIPrefBranch> pref_branch;
     rv = pref_service->GetBranch(nullptr, getter_AddRefs(pref_branch));
     if (NS_SUCCEEDED(rv)) {
       rv = pref_branch->GetCharPref(
           "media.peerconnection.nat_simulator.mapping_type",
-          mapping_type);
+          getter_Copies(mapping_type));
       rv = pref_branch->GetCharPref(
           "media.peerconnection.nat_simulator.filtering_type",
-          filtering_type);
+          getter_Copies(filtering_type));
       rv = pref_branch->GetBoolPref(
           "media.peerconnection.nat_simulator.block_udp",
           &block_udp);
       rv = pref_branch->GetBoolPref(
           "media.peerconnection.nat_simulator.block_tcp",
           &block_tcp);
     }
   }
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -480,46 +480,41 @@ StrEscape(const char* aOriginal, nsCStri
 // If aSetDefault is set to true however, it sets the default value. This will
 // only affect the program behavior if the user does not have a value saved
 // over it for the particular preference. In addition, these will never be
 // saved out to disk.
 //
 // Each set returns PREF_VALUECHANGED if the user value changed (triggering a
 // callback), or PREF_NOERROR if the value was unchanged.
 static nsresult
-PREF_SetCStringPref(const char* aPrefName,
-                    const nsACString& aValue,
-                    bool aSetDefault)
-{
-  if (aValue.Length() > MAX_PREF_LENGTH) {
+PREF_SetCharPref(const char* aPrefName, const char* aValue, bool aSetDefault)
+{
+  if (strlen(aValue) > MAX_PREF_LENGTH) {
     return NS_ERROR_ILLEGAL_VALUE;
   }
 
-  // It's ok to stash a pointer to the temporary PromiseFlatCString's chars in
-  // pref because pref_HashPref() duplicates those chars.
   PrefValue pref;
-  const nsCString& flat = PromiseFlatCString(aValue);
-  pref.mStringVal = const_cast<char*>(flat.get());
+  pref.mStringVal = const_cast<char*>(aValue);
 
   return pref_HashPref(
     aPrefName, pref, PrefType::String, aSetDefault ? kPrefSetDefault : 0);
 }
 
-// Like PREF_SetCStringPref(), but for integers.
+// Like PREF_SetCharPref(), but for integers.
 static nsresult
 PREF_SetIntPref(const char* aPrefName, int32_t aValue, bool aSetDefault)
 {
   PrefValue pref;
   pref.mIntVal = aValue;
 
   return pref_HashPref(
     aPrefName, pref, PrefType::Int, aSetDefault ? kPrefSetDefault : 0);
 }
 
-// Like PREF_SetCStringPref(), but for booleans.
+// Like PREF_SetCharPref(), but for booleans.
 static nsresult
 PREF_SetBoolPref(const char* aPrefName, bool aValue, bool aSetDefault)
 {
   PrefValue pref;
   pref.mBoolVal = aValue;
 
   return pref_HashPref(
     aPrefName, pref, PrefType::Bool, aSetDefault ? kPrefSetDefault : 0);
@@ -535,17 +530,18 @@ static nsresult
 SetPrefValue(const char* aPrefName,
              const dom::PrefValue& aValue,
              WhichValue aWhich)
 {
   bool setDefault = (aWhich == DEFAULT_VALUE);
 
   switch (aValue.type()) {
     case dom::PrefValue::TnsCString:
-      return PREF_SetCStringPref(aPrefName, aValue.get_nsCString(), setDefault);
+      return PREF_SetCharPref(
+        aPrefName, aValue.get_nsCString().get(), setDefault);
 
     case dom::PrefValue::Tint32_t:
       return PREF_SetIntPref(aPrefName, aValue.get_int32_t(), setDefault);
 
     case dom::PrefValue::Tbool:
       return PREF_SetBoolPref(aPrefName, aValue.get_bool(), setDefault);
 
     default:
@@ -717,20 +713,19 @@ PREF_HasUserPref(const char* aPrefName)
   if (!gHashTable) {
     return false;
   }
 
   PrefHashEntry* pref = pref_HashTableLookup(aPrefName);
   return pref && pref->mPrefFlags.HasUserValue();
 }
 
+// This function allocates memory and the caller is responsible for freeing it.
 static nsresult
-PREF_GetCStringPref(const char* aPrefName,
-                    nsACString& aValueOut,
-                    bool aGetDefault)
+PREF_CopyCharPref(const char* aPrefName, char** aValueOut, bool aGetDefault)
 {
   if (!gHashTable) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   nsresult rv = NS_ERROR_UNEXPECTED;
   char* stringVal;
   PrefHashEntry* pref = pref_HashTableLookup(aPrefName);
@@ -739,17 +734,17 @@ PREF_GetCStringPref(const char* aPrefNam
     if (aGetDefault || pref->mPrefFlags.IsLocked() ||
         !pref->mPrefFlags.HasUserValue()) {
       stringVal = pref->mDefaultPref.mStringVal;
     } else {
       stringVal = pref->mUserPref.mStringVal;
     }
 
     if (stringVal) {
-      aValueOut = stringVal;
+      *aValueOut = moz_xstrdup(stringVal);
       rv = NS_OK;
     }
   }
 
   return rv;
 }
 
 // Get an int preference. This function takes a dotted notation of the
@@ -2233,23 +2228,24 @@ protected:
   };
 
   virtual ~nsPrefBranch();
 
   nsresult GetDefaultFromPropertiesFile(const char* aPrefName,
                                         nsAString& aReturn);
 
   // As SetCharPref, but without any check on the length of |aValue|.
-  nsresult SetCharPrefInternal(const char* aPrefName, const nsACString& aValue);
+  nsresult SetCharPrefInternal(const char* aPrefName, const char* aValue);
 
   // Reject strings that are more than 1Mb, warn if strings are more than 16kb.
   nsresult CheckSanityOfStringLength(const char* aPrefName,
                                      const nsAString& aValue);
   nsresult CheckSanityOfStringLength(const char* aPrefName,
                                      const nsACString& aValue);
+  nsresult CheckSanityOfStringLength(const char* aPrefName, const char* aValue);
   nsresult CheckSanityOfStringLength(const char* aPrefName,
                                      const uint32_t aLength);
 
   void RemoveExpiredCallback(PrefCallback* aCallback);
 
   PrefName GetPrefName(const char* aPrefName) const;
 
   void FreeObserverList(void);
@@ -2332,19 +2328,21 @@ NS_IMPL_RELEASE(nsPrefBranch)
 NS_INTERFACE_MAP_BEGIN(nsPrefBranch)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrefBranch)
   NS_INTERFACE_MAP_ENTRY(nsIPrefBranch)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
-nsPrefBranch::GetRoot(nsACString& aRoot)
-{
-  aRoot = mPrefRoot;
+nsPrefBranch::GetRoot(char** aRoot)
+{
+  NS_ENSURE_ARG_POINTER(aRoot);
+
+  *aRoot = ToNewCString(mPrefRoot);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPrefBranch::GetPrefType(const char* aPrefName, int32_t* aRetVal)
 {
   NS_ENSURE_ARG(aPrefName);
   const PrefName& pref = GetPrefName(aPrefName);
@@ -2420,77 +2418,79 @@ nsPrefBranch::GetFloatPrefWithDefault(co
 }
 
 NS_IMETHODIMP
 nsPrefBranch::GetFloatPref(const char* aPrefName, float* aRetVal)
 {
   NS_ENSURE_ARG(aPrefName);
 
   nsAutoCString stringVal;
-  nsresult rv = GetCharPref(aPrefName, stringVal);
+  nsresult rv = GetCharPref(aPrefName, getter_Copies(stringVal));
   if (NS_SUCCEEDED(rv)) {
     *aRetVal = stringVal.ToFloat(&rv);
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsPrefBranch::GetCharPrefWithDefault(const char* aPrefName,
-                                     const nsACString& aDefaultValue,
+                                     const char* aDefaultValue,
                                      uint8_t aArgc,
-                                     nsACString& aRetVal)
+                                     char** aRetVal)
 {
   nsresult rv = GetCharPref(aPrefName, aRetVal);
 
   if (NS_FAILED(rv) && aArgc == 1) {
-    aRetVal = aDefaultValue;
+    NS_ENSURE_ARG(aDefaultValue);
+    *aRetVal = moz_xstrdup(aDefaultValue);
     return NS_OK;
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsPrefBranch::GetCharPref(const char* aPrefName, nsACString& aRetVal)
+nsPrefBranch::GetCharPref(const char* aPrefName, char** aRetVal)
 {
   NS_ENSURE_ARG(aPrefName);
   const PrefName& pref = GetPrefName(aPrefName);
-  return PREF_GetCStringPref(pref.get(), aRetVal, mIsDefault);
+  return PREF_CopyCharPref(pref.get(), aRetVal, mIsDefault);
 }
 
 NS_IMETHODIMP
-nsPrefBranch::SetCharPref(const char* aPrefName, const nsACString& aValue)
+nsPrefBranch::SetCharPref(const char* aPrefName, const char* aValue)
 {
   nsresult rv = CheckSanityOfStringLength(aPrefName, aValue);
   if (NS_FAILED(rv)) {
     return rv;
   }
   return SetCharPrefInternal(aPrefName, aValue);
 }
 
 nsresult
-nsPrefBranch::SetCharPrefInternal(const char* aPrefName,
-                                  const nsACString& aValue)
+nsPrefBranch::SetCharPrefInternal(const char* aPrefName, const char* aValue)
+
 {
   ENSURE_MAIN_PROCESS("SetCharPref", aPrefName);
   NS_ENSURE_ARG(aPrefName);
+  NS_ENSURE_ARG(aValue);
 
   const PrefName& pref = GetPrefName(aPrefName);
-  return PREF_SetCStringPref(pref.get(), aValue, mIsDefault);
+  return PREF_SetCharPref(pref.get(), aValue, mIsDefault);
 }
 
 NS_IMETHODIMP
 nsPrefBranch::GetStringPref(const char* aPrefName,
                             const nsACString& aDefaultValue,
                             uint8_t aArgc,
                             nsACString& aRetVal)
 {
   nsCString utf8String;
-  nsresult rv = GetCharPref(aPrefName, utf8String);
+  nsresult rv = GetCharPref(aPrefName, getter_Copies(utf8String));
   if (NS_SUCCEEDED(rv)) {
     aRetVal = utf8String;
     return rv;
   }
 
   if (aArgc == 1) {
     aRetVal = aDefaultValue;
     return NS_OK;
@@ -2502,17 +2502,17 @@ nsPrefBranch::GetStringPref(const char* 
 NS_IMETHODIMP
 nsPrefBranch::SetStringPref(const char* aPrefName, const nsACString& aValue)
 {
   nsresult rv = CheckSanityOfStringLength(aPrefName, aValue);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  return SetCharPrefInternal(aPrefName, aValue);
+  return SetCharPrefInternal(aPrefName, PromiseFlatCString(aValue).get());
 }
 
 NS_IMETHODIMP
 nsPrefBranch::GetIntPrefWithDefault(const char* aPrefName,
                                     int32_t aDefaultValue,
                                     uint8_t aArgc,
                                     int32_t* aRetVal)
 {
@@ -2546,17 +2546,17 @@ nsPrefBranch::SetIntPref(const char* aPr
 NS_IMETHODIMP
 nsPrefBranch::GetComplexValue(const char* aPrefName,
                               const nsIID& aType,
                               void** aRetVal)
 {
   NS_ENSURE_ARG(aPrefName);
 
   nsresult rv;
-  nsAutoCString utf8String;
+  nsCString utf8String;
 
   // we have to do this one first because it's different than all the rest
   if (aType.Equals(NS_GET_IID(nsIPrefLocalizedString))) {
     nsCOMPtr<nsIPrefLocalizedString> theString(
       do_CreateInstance(NS_PREFLOCALIZEDSTRING_CONTRACTID, &rv));
     if (NS_FAILED(rv)) {
       return rv;
     }
@@ -2577,31 +2577,31 @@ nsPrefBranch::GetComplexValue(const char
     // value we pulled in at the top of this function
     if (bNeedDefault) {
       nsAutoString utf16String;
       rv = GetDefaultFromPropertiesFile(pref.get(), utf16String);
       if (NS_SUCCEEDED(rv)) {
         theString->SetData(utf16String);
       }
     } else {
-      rv = GetCharPref(aPrefName, utf8String);
+      rv = GetCharPref(aPrefName, getter_Copies(utf8String));
       if (NS_SUCCEEDED(rv)) {
         theString->SetData(NS_ConvertUTF8toUTF16(utf8String));
       }
     }
 
     if (NS_SUCCEEDED(rv)) {
       theString.forget(reinterpret_cast<nsIPrefLocalizedString**>(aRetVal));
     }
 
     return rv;
   }
 
   // if we can't get the pref, there's no point in being here
-  rv = GetCharPref(aPrefName, utf8String);
+  rv = GetCharPref(aPrefName, getter_Copies(utf8String));
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   if (aType.Equals(NS_GET_IID(nsIFile))) {
     if (XRE_IsContentProcess()) {
       NS_ERROR("cannot get nsIFile pref from content process");
       return NS_ERROR_NOT_AVAILABLE;
@@ -2703,16 +2703,26 @@ nsPrefBranch::GetComplexValue(const char
   }
 
   NS_WARNING("nsPrefBranch::GetComplexValue - Unsupported interface type");
   return NS_NOINTERFACE;
 }
 
 nsresult
 nsPrefBranch::CheckSanityOfStringLength(const char* aPrefName,
+                                        const char* aValue)
+{
+  if (!aValue) {
+    return NS_OK;
+  }
+  return CheckSanityOfStringLength(aPrefName, strlen(aValue));
+}
+
+nsresult
+nsPrefBranch::CheckSanityOfStringLength(const char* aPrefName,
                                         const nsAString& aValue)
 {
   return CheckSanityOfStringLength(aPrefName, aValue.Length());
 }
 
 nsresult
 nsPrefBranch::CheckSanityOfStringLength(const char* aPrefName,
                                         const nsACString& aValue)
@@ -2781,17 +2791,17 @@ nsPrefBranch::SetComplexValue(const char
     nsCOMPtr<nsIFile> file = do_QueryInterface(aValue);
     if (!file) {
       return NS_NOINTERFACE;
     }
 
     nsAutoCString descriptorString;
     rv = file->GetPersistentDescriptor(descriptorString);
     if (NS_SUCCEEDED(rv)) {
-      rv = SetCharPrefInternal(aPrefName, descriptorString);
+      rv = SetCharPrefInternal(aPrefName, descriptorString.get());
     }
     return rv;
   }
 
   if (aType.Equals(NS_GET_IID(nsIRelativeFilePref))) {
     nsCOMPtr<nsIRelativeFilePref> relFilePref = do_QueryInterface(aValue);
     if (!relFilePref) {
       return NS_NOINTERFACE;
@@ -2825,34 +2835,35 @@ nsPrefBranch::SetComplexValue(const char
       return rv;
     }
 
     nsAutoCString descriptorString;
     descriptorString.Append('[');
     descriptorString.Append(relativeToKey);
     descriptorString.Append(']');
     descriptorString.Append(relDescriptor);
-    return SetCharPrefInternal(aPrefName, descriptorString);
+    return SetCharPrefInternal(aPrefName, descriptorString.get());
   }
 
   if (aType.Equals(NS_GET_IID(nsISupportsString)) ||
       aType.Equals(NS_GET_IID(nsIPrefLocalizedString))) {
     nsCOMPtr<nsISupportsString> theString = do_QueryInterface(aValue);
 
     if (theString) {
       nsString wideString;
 
       rv = theString->GetData(wideString);
       if (NS_SUCCEEDED(rv)) {
         // Check sanity of string length before any lengthy conversion
         rv = CheckSanityOfStringLength(aPrefName, wideString);
         if (NS_FAILED(rv)) {
           return rv;
         }
-        rv = SetCharPrefInternal(aPrefName, NS_ConvertUTF16toUTF8(wideString));
+        rv = SetCharPrefInternal(aPrefName,
+                                 NS_ConvertUTF16toUTF8(wideString).get());
       }
     }
     return rv;
   }
 
   NS_WARNING("nsPrefBranch::SetComplexValue - Unsupported interface type");
   return NS_NOINTERFACE;
 }
@@ -3133,18 +3144,19 @@ nsPrefBranch::RemoveExpiredCallback(Pref
 }
 
 nsresult
 nsPrefBranch::GetDefaultFromPropertiesFile(const char* aPrefName,
                                            nsAString& aReturn)
 {
   // The default value contains a URL to a .properties file.
 
-  nsAutoCString propertyFileURL;
-  nsresult rv = PREF_GetCStringPref(aPrefName, propertyFileURL, true);
+  nsCString propertyFileURL;
+  nsresult rv =
+    PREF_CopyCharPref(aPrefName, getter_Copies(propertyFileURL), true);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   nsCOMPtr<nsIStringBundleService> bundleService =
     mozilla::services::GetStringBundleService();
   if (!bundleService) {
     return NS_ERROR_FAILURE;
@@ -3961,26 +3973,26 @@ Preferences::Init()
     for (unsigned int i = 0; i < gInitPrefs->Length(); i++) {
       Preferences::SetPreference(gInitPrefs->ElementAt(i));
     }
     delete gInitPrefs;
     gInitPrefs = nullptr;
     return Ok();
   }
 
-  nsAutoCString lockFileName;
+  nsCString lockFileName;
 
   // The following is a small hack which will allow us to only load the library
   // which supports the netscape.cfg file if the preference is defined. We
   // test for the existence of the pref, set in the all.js (mozilla) or
   // all-ns.js (netscape 6), and if it exists we startup the pref config
   // category which will do the rest.
 
-  nsresult rv =
-    PREF_GetCStringPref("general.config.filename", lockFileName, false);
+  nsresult rv = PREF_CopyCharPref(
+    "general.config.filename", getter_Copies(lockFileName), false);
   if (NS_SUCCEEDED(rv)) {
     NS_CreateServicesFromCategory(
       "pref-config-startup",
       static_cast<nsISupports*>(static_cast<void*>(this)),
       "pref-config-startup");
   }
 
   nsCOMPtr<nsIObserverService> observerService =
@@ -4897,36 +4909,41 @@ Preferences::GetInt(const char* aPref, i
 }
 
 /* static */ nsresult
 Preferences::GetFloat(const char* aPref, float* aResult)
 {
   NS_PRECONDITION(aResult, "aResult must not be NULL");
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   nsAutoCString result;
-  nsresult rv = PREF_GetCStringPref(aPref, result, false);
+  nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
   if (NS_SUCCEEDED(rv)) {
     *aResult = result.ToFloat(&rv);
   }
   return rv;
 }
 
 /* static */ nsresult
 Preferences::GetCString(const char* aPref, nsACString& aResult)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_GetCStringPref(aPref, aResult, false);
+  char* result;
+  nsresult rv = PREF_CopyCharPref(aPref, &result, false);
+  if (NS_SUCCEEDED(rv)) {
+    aResult.Adopt(result);
+  }
+  return rv;
 }
 
 /* static */ nsresult
 Preferences::GetString(const char* aPref, nsAString& aResult)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   nsAutoCString result;
-  nsresult rv = PREF_GetCStringPref(aPref, result, false);
+  nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
   if (NS_SUCCEEDED(rv)) {
     CopyUTF8toUTF16(result, aResult);
   }
   return rv;
 }
 
 /* static */ nsresult
 Preferences::GetLocalizedCString(const char* aPref, nsACString& aResult)
@@ -4960,41 +4977,41 @@ Preferences::GetComplex(const char* aPre
   return sRootBranch->GetComplexValue(aPref, aType, aResult);
 }
 
 /* static */ nsresult
 Preferences::SetCString(const char* aPref, const char* aValue)
 {
   ENSURE_MAIN_PROCESS_WITH_WARNING("SetCString", aPref);
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_SetCStringPref(aPref, nsDependentCString(aValue), false);
+  return PREF_SetCharPref(aPref, aValue, false);
 }
 
 /* static */ nsresult
 Preferences::SetCString(const char* aPref, const nsACString& aValue)
 {
   ENSURE_MAIN_PROCESS_WITH_WARNING("SetCString", aPref);
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_SetCStringPref(aPref, aValue, false);
+  return PREF_SetCharPref(aPref, PromiseFlatCString(aValue).get(), false);
 }
 
 /* static */ nsresult
 Preferences::SetString(const char* aPref, const char16ptr_t aValue)
 {
   ENSURE_MAIN_PROCESS_WITH_WARNING("SetString", aPref);
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_SetCStringPref(aPref, NS_ConvertUTF16toUTF8(aValue), false);
+  return PREF_SetCharPref(aPref, NS_ConvertUTF16toUTF8(aValue).get(), false);
 }
 
 /* static */ nsresult
 Preferences::SetString(const char* aPref, const nsAString& aValue)
 {
   ENSURE_MAIN_PROCESS_WITH_WARNING("SetString", aPref);
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_SetCStringPref(aPref, NS_ConvertUTF16toUTF8(aValue), false);
+  return PREF_SetCharPref(aPref, NS_ConvertUTF16toUTF8(aValue).get(), false);
 }
 
 /* static */ nsresult
 Preferences::SetBool(const char* aPref, bool aValue)
 {
   ENSURE_MAIN_PROCESS_WITH_WARNING("SetBool", aPref);
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   return PREF_SetBoolPref(aPref, aValue, false);
@@ -5383,25 +5400,30 @@ Preferences::GetDefaultInt(const char* a
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   return PREF_GetIntPref(aPref, aResult, true);
 }
 
 /* static */ nsresult
 Preferences::GetDefaultCString(const char* aPref, nsACString& aResult)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_GetCStringPref(aPref, aResult, true);
+  char* result;
+  nsresult rv = PREF_CopyCharPref(aPref, &result, true);
+  if (NS_SUCCEEDED(rv)) {
+    aResult.Adopt(result);
+  }
+  return rv;
 }
 
 /* static */ nsresult
 Preferences::GetDefaultString(const char* aPref, nsAString& aResult)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   nsAutoCString result;
-  nsresult rv = PREF_GetCStringPref(aPref, result, true);
+  nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), true);
   if (NS_SUCCEEDED(rv)) {
     CopyUTF8toUTF16(result, aResult);
   }
   return rv;
 }
 
 /* static */ nsresult
 Preferences::GetDefaultLocalizedCString(const char* aPref, nsACString& aResult)
--- a/modules/libpref/nsIPrefBranch.idl
+++ b/modules/libpref/nsIPrefBranch.idl
@@ -36,17 +36,17 @@ interface nsIPrefBranch : nsISupports
   const long PREF_STRING = 32;
   const long PREF_INT = 64;
   const long PREF_BOOL = 128;
 
   /**
    * Called to get the root on which this branch is based, such as
    * "browser.startup."
    */
-  readonly attribute ACString root;
+  readonly attribute string root;
 
   /**
    * Called to determine the type of a specific preference.
    *
    * @param aPrefName The preference to get the type of.
    *
    * @return long     A value representing the type of the preference. This
    *                  value will be PREF_STRING, PREF_INT, or PREF_BOOL.
@@ -99,46 +99,45 @@ interface nsIPrefBranch : nsISupports
   float getFloatPrefXPCOM(in string aPrefName);
 
   /**
    * Called to get the state of an individual ascii string preference.
    *
    * @param aPrefName The string preference to retrieve.
    * @param aDefaultValue The string to return if the preference is not set.
    *
-   * @return ACString   The value of the requested string preference.
+   * @return string   The value of the requested string preference.
    *
    * @see setCharPref
    */
   [optional_argc,binaryname(GetCharPrefWithDefault)]
-  ACString getCharPref(in string aPrefName,
-                       [optional] in ACString aDefaultValue);
+  string getCharPref(in string aPrefName, [optional] in string aDefaultValue);
   [noscript,binaryname(GetCharPref)]
-  ACString getCharPrefXPCOM(in string aPrefName);
+  string getCharPrefXPCOM(in string aPrefName);
 
   /**
    * Called to set the state of an individual ascii string preference.
    *
    * @param aPrefName The string preference to set.
    * @param aValue    The string value to set the preference to.
    *
    * @throws Error if setting failed or the preference has a default
              value of a type other than string.
    *
    * @see getCharPref
    */
-  void setCharPref(in string aPrefName, in ACString aValue);
+  void setCharPref(in string aPrefName, in string aValue);
 
   /**
    * Called to get the state of an individual unicode string preference.
    *
    * @param aPrefName The string preference to retrieve.
    * @param aDefaultValue The string to return if the preference is not set.
    *
-   * @return ACString   The value of the requested string preference.
+   * @return string   The value of the requested string preference.
    *
    * @see setStringPref
    */
   [optional_argc]
   AUTF8String getStringPref(in string aPrefName,
                             [optional] in AUTF8String aDefaultValue);
 
   /**
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -1359,20 +1359,20 @@ nsIOService::PrefsChanged(nsIPrefBranch 
             }
         }
     }
 }
 
 void
 nsIOService::ParsePortList(nsIPrefBranch *prefBranch, const char *pref, bool remove)
 {
-    nsAutoCString portList;
+    nsCString portList;
 
     // Get a pref string and chop it up into a list of ports.
-    prefBranch->GetCharPref(pref, portList);
+    prefBranch->GetCharPref(pref, getter_Copies(portList));
     if (!portList.IsVoid()) {
         nsTArray<nsCString> portListArray;
         ParseString(portList, ',', portListArray);
         uint32_t index;
         for (index=0; index < portListArray.Length(); index++) {
             portListArray[index].StripWhitespace();
             int32_t portBegin, portEnd;
 
--- a/netwerk/base/nsProtocolProxyService.cpp
+++ b/netwerk/base/nsProtocolProxyService.cpp
@@ -422,18 +422,18 @@ proxy_MaskIPv6Addr(PRIPv6Addr &addr, uin
     }
 }
 
 static void
 proxy_GetStringPref(nsIPrefBranch *aPrefBranch,
                     const char    *aPref,
                     nsCString     &aResult)
 {
-    nsAutoCString temp;
-    nsresult rv = aPrefBranch->GetCharPref(aPref, temp);
+    nsCString temp;
+    nsresult rv = aPrefBranch->GetCharPref(aPref, getter_Copies(temp));
     if (NS_FAILED(rv))
         aResult.Truncate();
     else {
         aResult.Assign(temp);
         // all of our string prefs are hostnames, so we should remove any
         // whitespace characters that the user might have unknowingly entered.
         aResult.StripWhitespace();
     }
@@ -555,18 +555,19 @@ nsProtocolProxyService::ReloadNetworkPAC
 
     int32_t type;
     nsresult rv = prefs->GetIntPref(PROXY_PREF("type"), &type);
     if (NS_FAILED(rv)) {
         return NS_OK;
     }
 
     if (type == PROXYCONFIG_PAC) {
-        nsAutoCString pacSpec;
-        prefs->GetCharPref(PROXY_PREF("autoconfig_url"), pacSpec);
+        nsCString pacSpec;
+        prefs->GetCharPref(PROXY_PREF("autoconfig_url"),
+                           getter_Copies(pacSpec));
         if (!pacSpec.IsEmpty()) {
             nsCOMPtr<nsIURI> pacURI;
             rv = NS_NewURI(getter_AddRefs(pacURI), pacSpec);
             if(!NS_SUCCEEDED(rv)) {
                 return rv;
             }
 
             nsProtocolInfo pac;
@@ -686,17 +687,17 @@ nsProtocolProxyService::Observe(nsISuppo
 }
 
 void
 nsProtocolProxyService::PrefsChanged(nsIPrefBranch *prefBranch,
                                      const char    *pref)
 {
     nsresult rv = NS_OK;
     bool reloadPAC = false;
-    nsAutoCString tempString;
+    nsCString tempString;
 
     if (!pref || !strcmp(pref, PROXY_PREF("type"))) {
         int32_t type = -1;
         rv = prefBranch->GetIntPref(PROXY_PREF("type"), &type);
         if (NS_SUCCEEDED(rv)) {
             // bug 115720 - for ns4.x backwards compatibility
             if (type == PROXYCONFIG_DIRECT4X) {
                 type = PROXYCONFIG_DIRECT;
@@ -770,17 +771,18 @@ nsProtocolProxyService::PrefsChanged(nsI
                           mProxyOverTLS);
     }
 
     if (!pref || !strcmp(pref, PROXY_PREF("failover_timeout")))
         proxy_GetIntPref(prefBranch, PROXY_PREF("failover_timeout"),
                          mFailedProxyTimeout);
 
     if (!pref || !strcmp(pref, PROXY_PREF("no_proxies_on"))) {
-        rv = prefBranch->GetCharPref(PROXY_PREF("no_proxies_on"), tempString);
+        rv = prefBranch->GetCharPref(PROXY_PREF("no_proxies_on"),
+                                     getter_Copies(tempString));
         if (NS_SUCCEEDED(rv))
             LoadHostFilters(tempString);
     }
 
     // We're done if not using something that could give us a PAC URL
     // (PAC, WPAD or System)
     if (mProxyConfig != PROXYCONFIG_PAC && mProxyConfig != PROXYCONFIG_WPAD &&
         mProxyConfig != PROXYCONFIG_SYSTEM)
@@ -791,17 +793,18 @@ nsProtocolProxyService::PrefsChanged(nsI
     //  2) network.proxy.autoconfig_url changed and PAC is configured
 
     if (!pref || !strcmp(pref, PROXY_PREF("autoconfig_url")))
         reloadPAC = true;
 
     if (reloadPAC) {
         tempString.Truncate();
         if (mProxyConfig == PROXYCONFIG_PAC) {
-            prefBranch->GetCharPref(PROXY_PREF("autoconfig_url"), tempString);
+            prefBranch->GetCharPref(PROXY_PREF("autoconfig_url"),
+                                    getter_Copies(tempString));
             if (mPACMan && !mPACMan->IsPACURI(tempString)) {
                 LOG(("PAC Thread URI Changed - Reset Pac Thread"));
                 ResetPACThread();
             }
         } else if (mProxyConfig == PROXYCONFIG_WPAD) {
             // We diverge from the WPAD spec here in that we don't walk the
             // hosts's FQDN, stripping components until we hit a TLD.  Doing so
             // is dangerous in the face of an incomplete list of TLDs, and TLDs
@@ -1238,19 +1241,19 @@ nsProtocolProxyService::ReloadPAC()
     if (!prefs)
         return NS_OK;
 
     int32_t type;
     nsresult rv = prefs->GetIntPref(PROXY_PREF("type"), &type);
     if (NS_FAILED(rv))
         return NS_OK;
 
-    nsAutoCString pacSpec;
+    nsCString pacSpec;
     if (type == PROXYCONFIG_PAC)
-        prefs->GetCharPref(PROXY_PREF("autoconfig_url"), pacSpec);
+        prefs->GetCharPref(PROXY_PREF("autoconfig_url"), getter_Copies(pacSpec));
     else if (type == PROXYCONFIG_WPAD)
         pacSpec.AssignLiteral(WPAD_URL);
     else if (type == PROXYCONFIG_SYSTEM) {
         if (mSystemProxySettings) {
             AsyncConfigureFromPAC(true, true);
         } else {
             ResetPACThread();
         }
--- a/netwerk/dns/nsDNSService2.cpp
+++ b/netwerk/dns/nsDNSService2.cpp
@@ -542,36 +542,36 @@ nsDNSService::Init()
     uint32_t defaultGracePeriod = 60; // seconds
     bool     disableIPv6      = false;
     bool     offlineLocalhost = true;
     bool     disablePrefetch  = false;
     bool     blockDotOnion    = true;
     int      proxyType        = nsIProtocolProxyService::PROXYCONFIG_DIRECT;
     bool     notifyResolution = false;
 
-    nsAutoCString ipv4OnlyDomains;
-    nsAutoCString localDomains;
-    nsAutoCString forceResolve;
+    nsCString ipv4OnlyDomains;
+    nsCString localDomains;
+    nsCString forceResolve;
 
     // read prefs
     nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
     if (prefs) {
         int32_t val;
         if (NS_SUCCEEDED(prefs->GetIntPref(kPrefDnsCacheEntries, &val)))
             maxCacheEntries = (uint32_t) val;
         if (NS_SUCCEEDED(prefs->GetIntPref(kPrefDnsCacheExpiration, &val)))
             defaultCacheLifetime = val;
         if (NS_SUCCEEDED(prefs->GetIntPref(kPrefDnsCacheGrace, &val)))
             defaultGracePeriod = val;
 
         // ASSUMPTION: pref branch does not modify out params on failure
         prefs->GetBoolPref(kPrefDisableIPv6, &disableIPv6);
-        prefs->GetCharPref(kPrefIPv4OnlyDomains, ipv4OnlyDomains);
-        prefs->GetCharPref(kPrefDnsLocalDomains, localDomains);
-        prefs->GetCharPref(kPrefDnsForceResolve, forceResolve);
+        prefs->GetCharPref(kPrefIPv4OnlyDomains, getter_Copies(ipv4OnlyDomains));
+        prefs->GetCharPref(kPrefDnsLocalDomains, getter_Copies(localDomains));
+        prefs->GetCharPref(kPrefDnsForceResolve, getter_Copies(forceResolve));
         prefs->GetBoolPref(kPrefDnsOfflineLocalhost, &offlineLocalhost);
         prefs->GetBoolPref(kPrefDisablePrefetch, &disablePrefetch);
         prefs->GetBoolPref(kPrefBlockDotOnion, &blockDotOnion);
 
         // If a manual proxy is in use, disable prefetch implicitly
         prefs->GetIntPref("network.proxy.type", &proxyType);
         prefs->GetBoolPref(kPrefDnsNotifyResolution, &notifyResolution);
 
--- a/netwerk/dns/nsIDNService.cpp
+++ b/netwerk/dns/nsIDNService.cpp
@@ -118,19 +118,19 @@ void nsIDNService::prefsChanged(nsIPrefB
   }
   if (!pref || NS_LITERAL_STRING(NS_NET_PREF_IDNUSEWHITELIST).Equals(pref)) {
     bool val;
     if (NS_SUCCEEDED(prefBranch->GetBoolPref(NS_NET_PREF_IDNUSEWHITELIST,
                                              &val)))
       mIDNUseWhitelist = val;
   }
   if (!pref || NS_LITERAL_STRING(NS_NET_PREF_IDNRESTRICTION).Equals(pref)) {
-    nsAutoCString profile;
+    nsCString profile;
     if (NS_FAILED(prefBranch->GetCharPref(NS_NET_PREF_IDNRESTRICTION,
-                                          profile))) {
+                                          getter_Copies(profile)))) {
       profile.Truncate();
     }
     if (profile.EqualsLiteral("moderate")) {
       mRestrictionProfile = eModeratelyRestrictiveProfile;
     } else if (profile.EqualsLiteral("high")) {
       mRestrictionProfile = eHighlyRestrictiveProfile;
     } else {
       mRestrictionProfile = eASCIIOnlyProfile;
--- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
+++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
@@ -780,25 +780,25 @@ nsFtpState::S_pass() {
 
     mResponseMsg = "";
 
     if (mAnonymous) {
         if (!mPassword.IsEmpty()) {
             // XXX Is UTF-8 the best choice?
             AppendUTF16toUTF8(mPassword, passwordStr);
         } else {
-            nsAutoCString anonPassword;
+            nsCString anonPassword;
             bool useRealEmail = false;
             nsCOMPtr<nsIPrefBranch> prefs =
                     do_GetService(NS_PREFSERVICE_CONTRACTID);
             if (prefs) {
                 rv = prefs->GetBoolPref("advanced.mailftp", &useRealEmail);
                 if (NS_SUCCEEDED(rv) && useRealEmail) {
                     prefs->GetCharPref("network.ftp.anonymous_password",
-                                       anonPassword);
+                                       getter_Copies(anonPassword));
                 }
             }
             if (!anonPassword.IsEmpty()) {
                 passwordStr.AppendASCII(anonPassword.get());
             } else {
                 // We need to default to a valid email address - bug 101027
                 // example.com is reserved (rfc2606), so use that
                 passwordStr.AppendLiteral("mozilla@example.com");
--- a/netwerk/protocol/gio/nsGIOProtocolHandler.cpp
+++ b/netwerk/protocol/gio/nsGIOProtocolHandler.cpp
@@ -919,17 +919,17 @@ void
 nsGIOProtocolHandler::InitSupportedProtocolsPref(nsIPrefBranch *prefs)
 {
   // Get user preferences to determine which protocol is supported.
   // Gvfs/GIO has a set of supported protocols like obex, network, archive,
   // computer, dav, cdda, gphoto2, trash, etc. Some of these seems to be
   // irrelevant to process by browser. By default accept only smb and sftp
   // protocols so far.
   nsresult rv = prefs->GetCharPref(MOZ_GIO_SUPPORTED_PROTOCOLS,
-                                   mSupportedProtocols);
+                                   getter_Copies(mSupportedProtocols));
   if (NS_SUCCEEDED(rv)) {
     mSupportedProtocols.StripWhitespace();
     ToLowerCase(mSupportedProtocols);
   }
   else
     mSupportedProtocols.AssignLiteral("smb:,sftp:"); // use defaults
 
   LOG(("gio: supported protocols \"%s\"\n", mSupportedProtocols.get()));
--- a/netwerk/protocol/http/HttpAuthUtils.cpp
+++ b/netwerk/protocol/http/HttpAuthUtils.cpp
@@ -132,21 +132,25 @@ URIMatchesPrefPattern(nsIURI *uri, const
     return false;
   }
 
   port = NS_GetRealPort(uri);
   if (port == -1) {
     return false;
   }
 
-  nsAutoCString hostList;
-  if (NS_FAILED(prefs->GetCharPref(pref, hostList)) || hostList.IsEmpty()) {
+  char *hostList;
+  if (NS_FAILED(prefs->GetCharPref(pref, &hostList)) || !hostList) {
     return false;
   }
 
+  struct FreePolicy { void operator()(void* p) { free(p); } };
+  mozilla::UniquePtr<char[], FreePolicy> hostListScope;
+  hostListScope.reset(hostList);
+
   // pseudo-BNF
   // ----------
   //
   // url-list       base-url ( base-url "," LWS )*
   // base-url       ( scheme-part | host-part | scheme-part host-part )
   // scheme-part    scheme "://"
   // host-part      host [":" port]
   //
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -1160,17 +1160,18 @@ nsHttpHandler::PrefsChanged(nsIPrefBranc
     if (PREF_CHANGED(UA_PREF("compatMode.firefox"))) {
         rv = prefs->GetBoolPref(UA_PREF("compatMode.firefox"), &cVar);
         mCompatFirefoxEnabled = (NS_SUCCEEDED(rv) && cVar);
         mUserAgentIsDirty = true;
     }
 
     // general.useragent.override
     if (PREF_CHANGED(UA_PREF("override"))) {
-        prefs->GetCharPref(UA_PREF("override"), mUserAgentOverride);
+        prefs->GetCharPref(UA_PREF("override"),
+                            getter_Copies(mUserAgentOverride));
         mUserAgentIsDirty = true;
     }
 
 #ifdef ANDROID
     // general.useragent.use_device
     if (PREF_CHANGED(UA_PREF("use_device"))) {
         if (Preferences::GetBool(UA_PREF("use_device"), false)) {
             mDeviceModelId = mozilla::net::GetDeviceModelId();
@@ -1337,77 +1338,80 @@ nsHttpHandler::PrefsChanged(nsIPrefBranc
 
     if (PREF_CHANGED(HTTP_PREF("fast-fallback-to-IPv4"))) {
         rv = prefs->GetBoolPref(HTTP_PREF("fast-fallback-to-IPv4"), &cVar);
         if (NS_SUCCEEDED(rv))
             mFastFallbackToIPv4 = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("version"))) {
-        nsAutoCString httpVersion;
-        prefs->GetCharPref(HTTP_PREF("version"), httpVersion);
+        nsCString httpVersion;
+        prefs->GetCharPref(HTTP_PREF("version"), getter_Copies(httpVersion));
         if (!httpVersion.IsVoid()) {
             if (httpVersion.EqualsLiteral("1.1"))
                 mHttpVersion = NS_HTTP_VERSION_1_1;
             else if (httpVersion.EqualsLiteral("0.9"))
                 mHttpVersion = NS_HTTP_VERSION_0_9;
             else
                 mHttpVersion = NS_HTTP_VERSION_1_0;
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("proxy.version"))) {
-        nsAutoCString httpVersion;
-        prefs->GetCharPref(HTTP_PREF("proxy.version"), httpVersion);
+        nsCString httpVersion;
+        prefs->GetCharPref(HTTP_PREF("proxy.version"), getter_Copies(httpVersion));
         if (!httpVersion.IsVoid()) {
             if (httpVersion.EqualsLiteral("1.1"))
                 mProxyHttpVersion = NS_HTTP_VERSION_1_1;
             else
                 mProxyHttpVersion = NS_HTTP_VERSION_1_0;
             // it does not make sense to issue a HTTP/0.9 request to a proxy server
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("qos"))) {
         rv = prefs->GetIntPref(HTTP_PREF("qos"), &val);
         if (NS_SUCCEEDED(rv))
             mQoSBits = (uint8_t) clamped(val, 0, 0xff);
     }
 
     if (PREF_CHANGED(HTTP_PREF("accept.default"))) {
-        nsAutoCString accept;
-        rv = prefs->GetCharPref(HTTP_PREF("accept.default"), accept);
+        nsCString accept;
+        rv = prefs->GetCharPref(HTTP_PREF("accept.default"),
+                                  getter_Copies(accept));
         if (NS_SUCCEEDED(rv)) {
             rv = SetAccept(accept.get());
             MOZ_ASSERT(NS_SUCCEEDED(rv));
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("accept-encoding"))) {
-        nsAutoCString acceptEncodings;
-        rv = prefs->GetCharPref(HTTP_PREF("accept-encoding"), acceptEncodings);
+        nsCString acceptEncodings;
+        rv = prefs->GetCharPref(HTTP_PREF("accept-encoding"),
+                                  getter_Copies(acceptEncodings));
         if (NS_SUCCEEDED(rv)) {
             rv = SetAcceptEncodings(acceptEncodings.get(), false);
             MOZ_ASSERT(NS_SUCCEEDED(rv));
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("accept-encoding.secure"))) {
-        nsAutoCString acceptEncodings;
+        nsCString acceptEncodings;
         rv = prefs->GetCharPref(HTTP_PREF("accept-encoding.secure"),
-                                acceptEncodings);
+                                  getter_Copies(acceptEncodings));
         if (NS_SUCCEEDED(rv)) {
             rv = SetAcceptEncodings(acceptEncodings.get(), true);
             MOZ_ASSERT(NS_SUCCEEDED(rv));
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("default-socket-type"))) {
-        nsAutoCString sval;
-        rv = prefs->GetCharPref(HTTP_PREF("default-socket-type"), sval);
+        nsCString sval;
+        rv = prefs->GetCharPref(HTTP_PREF("default-socket-type"),
+                                getter_Copies(sval));
         if (NS_SUCCEEDED(rv)) {
             if (sval.IsEmpty())
                 mDefaultSocketType.SetIsVoid(true);
             else {
                 // verify that this socket type is actually valid
                 nsCOMPtr<nsISocketProviderService> sps(
                         do_GetService(NS_SOCKETPROVIDERSERVICE_CONTRACTID));
                 if (sps) {
--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
+++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
@@ -144,19 +144,19 @@ nsTypeAheadFind::PrefsReset()
   NS_ENSURE_TRUE(prefBranch, NS_ERROR_FAILURE);
 
   prefBranch->GetBoolPref("accessibility.typeaheadfind.startlinksonly",
                           &mStartLinksOnlyPref);
 
   bool isSoundEnabled = true;
   prefBranch->GetBoolPref("accessibility.typeaheadfind.enablesound",
                            &isSoundEnabled);
-  nsAutoCString soundStr;
+  nsCString soundStr;
   if (isSoundEnabled)
-    prefBranch->GetCharPref("accessibility.typeaheadfind.soundURL", soundStr);
+    prefBranch->GetCharPref("accessibility.typeaheadfind.soundURL", getter_Copies(soundStr));
 
   mNotFoundSoundURL = soundStr;
 
   if (!mNotFoundSoundURL.IsEmpty() && !mNotFoundSoundURL.EqualsLiteral("beep")) {
     if (!mSoundInterface) {
       mSoundInterface = do_CreateInstance("@mozilla.org/sound;1");
     }
 
--- a/toolkit/components/url-classifier/nsUrlClassifierUtils.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierUtils.cpp
@@ -131,18 +131,19 @@ InitListUpdateRequest(ThreatType aThreat
 static ClientInfo*
 CreateClientInfo()
 {
   ClientInfo* c = new ClientInfo();
 
   nsCOMPtr<nsIPrefBranch> prefBranch =
     do_GetService(NS_PREFSERVICE_CONTRACTID);
 
-  nsAutoCString clientId;
-  nsresult rv = prefBranch->GetCharPref("browser.safebrowsing.id", clientId);
+  nsCString clientId;
+  nsresult rv = prefBranch->GetCharPref("browser.safebrowsing.id",
+                                        getter_Copies(clientId));
 
   if (NS_FAILED(rv)) {
     clientId = "Firefox"; // Use "Firefox" as fallback.
   }
 
   c->set_client_id(clientId.get());
 
   return c;
@@ -338,18 +339,18 @@ nsUrlClassifierUtils::GetTelemetryProvid
 NS_IMETHODIMP
 nsUrlClassifierUtils::GetProtocolVersion(const nsACString& aProvider,
                                          nsACString& aVersion)
 {
   nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
   if (prefBranch) {
       nsPrintfCString prefName("browser.safebrowsing.provider.%s.pver",
                                nsCString(aProvider).get());
-      nsAutoCString version;
-      nsresult rv = prefBranch->GetCharPref(prefName.get(), version);
+      nsCString version;
+      nsresult rv = prefBranch->GetCharPref(prefName.get(), getter_Copies(version));
 
       aVersion = NS_SUCCEEDED(rv) ? version.get() : DEFAULT_PROTOCOL_VERSION;
   } else {
       aVersion = DEFAULT_PROTOCOL_VERSION;
   }
 
   return NS_OK;
 }
@@ -830,18 +831,19 @@ nsUrlClassifierUtils::ReadProvidersFromP
   // Now we have all providers. Check which one owns |aTableName|.
   // e.g. The owning lists of provider "google" is defined in
   // "browser.safebrowsing.provider.google.lists".
   for (auto itr = providers.Iter(); !itr.Done(); itr.Next()) {
     auto entry = itr.Get();
     nsCString provider(entry->GetKey());
     nsPrintfCString owninListsPref("%s.lists", provider.get());
 
-    nsAutoCString owningLists;
-    nsresult rv = prefBranch->GetCharPref(owninListsPref.get(), owningLists);
+    nsCString owningLists;
+    nsresult rv = prefBranch->GetCharPref(owninListsPref.get(),
+                                          getter_Copies(owningLists));
     if (NS_FAILED(rv)) {
       continue;
     }
 
     // We've got the owning lists (represented as string) of |provider|.
     // Build the dictionary for the owning list and the current provider.
     nsTArray<nsCString> tables;
     Classifier::SplitTables(owningLists, tables);
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -4354,18 +4354,18 @@ XREMain::XRE_mainRun()
 #ifdef MOZ_CRASHREPORTER
   // tell the crash reporter to also send the release channel
   nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
   if (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIPrefBranch> defaultPrefBranch;
     rv = prefs->GetDefaultBranch(nullptr, getter_AddRefs(defaultPrefBranch));
 
     if (NS_SUCCEEDED(rv)) {
-      nsAutoCString sval;
-      rv = defaultPrefBranch->GetCharPref("app.update.channel", sval);
+      nsCString sval;
+      rv = defaultPrefBranch->GetCharPref("app.update.channel", getter_Copies(sval));
       if (NS_SUCCEEDED(rv)) {
         CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ReleaseChannel"),
                                             sval);
       }
     }
   }
   // Needs to be set after xpcom initialization.
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("FramePoisonBase"),