Backed out changeset ef5feef07bed (bug 1384835)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Fri, 28 Jul 2017 10:29:24 +0200
changeset 371510 88e14ba4308e1ca878548a2b1616276c7b543c39
parent 371509 66e6d95dace315b3aa6ad2c1f6f21d2aa8a9a063
child 371511 04539e21f0d579a537e1a6abab75d9b88258d6cd
push id93105
push userarchaeopteryx@coole-files.de
push dateFri, 28 Jul 2017 08:30:52 +0000
treeherdermozilla-inbound@b57e8e2ae846 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1384835
milestone56.0a1
backs outef5feef07bed07583c52e434dbc5e4b9a2545deb
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 ef5feef07bed (bug 1384835)
caps/nsScriptSecurityManager.cpp
chrome/nsChromeRegistryChrome.cpp
docshell/base/nsDefaultURIFixup.cpp
docshell/base/nsDocShell.cpp
dom/audiochannel/AudioChannelAgent.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsObjectLoadingContent.cpp
dom/base/nsPluginArray.cpp
dom/encoding/FallbackEncoding.cpp
dom/events/Event.cpp
dom/indexedDB/IndexedDatabaseManager.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/media/DecoderDoctorDiagnostics.cpp
dom/media/MediaManager.cpp
dom/media/webspeech/recognition/SpeechRecognition.cpp
dom/plugins/base/nsPluginHost.cpp
dom/presentation/provider/MulticastDNSDeviceProvider.cpp
dom/security/nsContentSecurityManager.cpp
editor/libeditor/HTMLEditRules.cpp
extensions/cookie/nsPermissionManager.cpp
gfx/gl/GLLibraryEGL.cpp
gfx/thebes/gfxDWriteFontList.cpp
gfx/thebes/gfxFcPlatformFontList.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatformFontList.cpp
gfx/vr/gfxVROSVR.cpp
image/imgLoader.cpp
intl/hyphenation/glue/nsHyphenationManager.cpp
intl/locale/android/OSPreferences_android.cpp
js/ipc/JavaScriptParent.cpp
layout/base/StaticPresData.cpp
layout/base/nsPresContext.cpp
modules/libpref/Preferences.cpp
modules/libpref/Preferences.h
netwerk/base/nsChannelClassifier.cpp
netwerk/protocol/http/nsHttpHandler.cpp
parser/html/nsHtml5StreamParser.cpp
security/apps/AppTrustDomain.cpp
security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
security/sandbox/linux/broker/SandboxBrokerPolicyFactory.h
uriloader/exthandler/nsExternalHelperAppService.cpp
widget/GfxInfoBase.cpp
widget/android/nsWindow.cpp
widget/gtk/nsLookAndFeel.cpp
widget/gtk/nsPSPrinters.cpp
xpcom/threads/BackgroundHangMonitor.cpp
xpfe/appshell/nsAppShellService.cpp
xpfe/appshell/nsXULWindow.cpp
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -1637,18 +1637,17 @@ nsScriptSecurityManager::EnsureFileURIWh
 
     //
     // Rebuild the set of principals for which we allow file:// URI loads. This
     // implements a small subset of an old pref-based CAPS people that people
     // have come to depend on. See bug 995943.
     //
 
     mFileURIWhitelist.emplace();
-    nsAutoCString policies;
-    mozilla::Preferences::GetCString("capability.policy.policynames", policies);
+    auto policies = mozilla::Preferences::GetCString("capability.policy.policynames");
     for (uint32_t base = SkipPast<IsWhitespaceOrComma>(policies, 0), bound = 0;
          base < policies.Length();
          base = SkipPast<IsWhitespaceOrComma>(policies, bound))
     {
         // Grab the current policy name.
         bound = SkipUntil<IsWhitespaceOrComma>(policies, base);
         auto policyName = Substring(policies, base, bound - base);
 
@@ -1661,15 +1660,14 @@ nsScriptSecurityManager::EnsureFileURIWh
         if (NS_FAILED(rv) || !value.LowerCaseEqualsLiteral("allaccess")) {
             continue;
         }
 
         // Grab the list of domains associated with this policy.
         nsCString domainPrefName = NS_LITERAL_CSTRING("capability.policy.") +
                                    policyName +
                                    NS_LITERAL_CSTRING(".sites");
-        nsAutoCString siteList;
-        Preferences::GetCString(domainPrefName.get(), siteList);
+        auto siteList = Preferences::GetCString(domainPrefName.get());
         AddSitesToFileURIWhitelist(siteList);
     }
 
     return mFileURIWhitelist.ref();
 }
--- a/chrome/nsChromeRegistryChrome.cpp
+++ b/chrome/nsChromeRegistryChrome.cpp
@@ -246,22 +246,21 @@ nsChromeRegistryChrome::GetSelectedLocal
   return NS_OK;
 }
 
 nsresult
 nsChromeRegistryChrome::OverrideLocalePackage(const nsACString& aPackage,
                                               nsACString& aOverride)
 {
   const nsACString& pref = NS_LITERAL_CSTRING(PACKAGE_OVERRIDE_BRANCH) + aPackage;
-  nsAutoCString override;
-  nsresult rv =
-    mozilla::Preferences::GetCString(PromiseFlatCString(pref).get(), override);
-  if (NS_SUCCEEDED(rv)) {
+  nsAdoptingCString override = mozilla::Preferences::GetCString(PromiseFlatCString(pref).get());
+  if (override) {
     aOverride = override;
-  } else {
+  }
+  else {
     aOverride = aPackage;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsChromeRegistryChrome::Observe(nsISupports *aSubject, const char *aTopic,
                                 const char16_t *someData)
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -573,27 +573,26 @@ nsDefaultURIFixup::MakeAlternateURI(nsIU
     }
     ++iter;
   }
 
   // Get the prefix and suffix to stick onto the new hostname. By default these
   // are www. & .com but they could be any other value, e.g. www. & .org
 
   nsAutoCString prefix("www.");
-  nsAutoCString prefPrefix;
-  nsresult rv =
-    Preferences::GetCString("browser.fixup.alternate.prefix", prefPrefix);
-  if (NS_SUCCEEDED(rv)) {
+  nsAdoptingCString prefPrefix =
+    Preferences::GetCString("browser.fixup.alternate.prefix");
+  if (prefPrefix) {
     prefix.Assign(prefPrefix);
   }
 
   nsAutoCString suffix(".com");
-  nsAutoCString prefSuffix;
-  rv = Preferences::GetCString("browser.fixup.alternate.suffix", prefSuffix);
-  if (NS_SUCCEEDED(rv)) {
+  nsAdoptingCString prefSuffix =
+    Preferences::GetCString("browser.fixup.alternate.suffix");
+  if (prefSuffix) {
     suffix.Assign(prefSuffix);
   }
 
   if (numDots == 0) {
     newHost.Assign(prefix);
     newHost.Append(oldHost);
     newHost.Append(suffix);
   } else if (numDots == 1) {
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -5094,21 +5094,19 @@ nsDocShell::DisplayLoadError(nsresult aE
           // measuring STS separately allows us to measure click through
           // rates easily
           bucketId = nsISecurityUITelemetry::WARNING_BAD_CERT_TOP_STS;
         } else {
           bucketId = nsISecurityUITelemetry::WARNING_BAD_CERT_TOP;
         }
 
         // See if an alternate cert error page is registered
-        nsAutoCString alternateErrorPage;
-        nsresult rv =
-          Preferences::GetCString("security.alternate_certificate_error_page",
-                                  alternateErrorPage);
-        if (NS_SUCCEEDED(rv)) {
+        nsAdoptingCString alternateErrorPage =
+          Preferences::GetCString("security.alternate_certificate_error_page");
+        if (alternateErrorPage) {
           errorPage.Assign(alternateErrorPage);
         }
 
         if (!IsFrame() && errorPage.EqualsIgnoreCase("certerror")) {
           Telemetry::Accumulate(mozilla::Telemetry::SECURITY_UI, bucketId);
         }
 
       } else {
@@ -5120,20 +5118,19 @@ nsDocShell::DisplayLoadError(nsresult aE
              NS_ERROR_UNWANTED_URI == aError) {
     nsAutoCString host;
     aURI->GetHost(host);
     CopyUTF8toUTF16(host, formatStrs[0]);
     formatStrCount = 1;
 
     // Malware and phishing detectors may want to use an alternate error
     // page, but if the pref's not set, we'll fall back on the standard page
-    nsAutoCString alternateErrorPage;
-    nsresult rv = Preferences::GetCString("urlclassifier.alternate_error_page",
-                                          alternateErrorPage);
-    if (NS_SUCCEEDED(rv)) {
+    nsAdoptingCString alternateErrorPage =
+      Preferences::GetCString("urlclassifier.alternate_error_page");
+    if (alternateErrorPage) {
       errorPage.Assign(alternateErrorPage);
     }
 
     uint32_t bucketId;
     bool sendTelemetry = false;
     if (NS_ERROR_PHISHING_URI == aError) {
       sendTelemetry = true;
       error = "deceptiveBlocked";
--- a/dom/audiochannel/AudioChannelAgent.cpp
+++ b/dom/audiochannel/AudioChannelAgent.cpp
@@ -113,20 +113,19 @@ AudioChannelAgent::FindCorrectWindow(nsP
   if (!doc) {
     return NS_OK;
   }
 
   if (nsContentUtils::IsChromeDoc(doc)) {
     return NS_OK;
   }
 
-  nsAutoCString systemAppUrl;
-  nsresult rv =
-    mozilla::Preferences::GetCString("b2g.system_startup_url", systemAppUrl);
-  if (NS_FAILED(rv)) {
+  nsAdoptingCString systemAppUrl =
+    mozilla::Preferences::GetCString("b2g.system_startup_url");
+  if (!systemAppUrl) {
     return NS_OK;
   }
 
   nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
   nsCOMPtr<nsIURI> uri;
   principal->GetURI(getter_AddRefs(uri));
 
   if (uri) {
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1700,21 +1700,22 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalW
 
     Preferences::AddUintVarCache(&gThrottledIdlePeriodLength,
                                  "dom.idle_period.throttled_length",
                                  DEFAULT_THROTTLED_IDLE_PERIOD_LENGTH);
     sFirstTime = false;
   }
 
   if (gDumpFile == nullptr) {
-    nsAutoCString fname;
-    Preferences::GetCString("browser.dom.window.dump.file", fname);
+    const nsAdoptingCString& fname =
+      Preferences::GetCString("browser.dom.window.dump.file");
     if (!fname.IsEmpty()) {
-      // If this fails to open, Dump() knows to just go to stdout on null.
-      gDumpFile = fopen(fname.get(), "wb+");
+      // if this fails to open, Dump() knows to just go to stdout
+      // on null.
+      gDumpFile = fopen(fname, "wb+");
     } else {
       gDumpFile = stdout;
     }
   }
 
   mSerial = ++gSerialCounter;
 
 #ifdef DEBUG
@@ -6935,18 +6936,17 @@ struct FullscreenTransitionDuration
 
 static void
 GetFullscreenTransitionDuration(bool aEnterFullscreen,
                                 FullscreenTransitionDuration* aDuration)
 {
   const char* pref = aEnterFullscreen ?
     "full-screen-api.transition-duration.enter" :
     "full-screen-api.transition-duration.leave";
-  nsAutoCString prefValue;
-  Preferences::GetCString(pref, prefValue);
+  nsAdoptingCString prefValue = Preferences::GetCString(pref);
   if (!prefValue.IsEmpty()) {
     sscanf(prefValue.get(), "%hu%hu",
            &aDuration->mFadeIn, &aDuration->mFadeOut);
   }
 }
 
 class FullscreenTransitionTask : public Runnable
 {
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -955,18 +955,17 @@ nsObjectLoadingContent::BuildParametersA
   bool isJava = IsJavaMIME(mContentType);
 
   nsCString codebase;
   if (isJava) {
       nsresult rv = mBaseURI->GetSpec(codebase);
       NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  nsAutoCString wmodeOverride;
-  Preferences::GetCString("plugins.force.wmode", wmodeOverride);
+  nsAdoptingCString wmodeOverride = Preferences::GetCString("plugins.force.wmode");
   for (uint32_t i = 0; i < mCachedAttributes.Length(); i++) {
     if (!wmodeOverride.IsEmpty() && mCachedAttributes[i].mName.EqualsIgnoreCase("wmode")) {
       CopyASCIItoUTF16(wmodeOverride, mCachedAttributes[i].mValue);
       wmodeOverride.Truncate();
     } else if (!codebase.IsEmpty() && mCachedAttributes[i].mName.EqualsIgnoreCase("codebase")) {
       CopyASCIItoUTF16(codebase, mCachedAttributes[i].mValue);
       codebase.Truncate();
     }
@@ -1659,17 +1658,18 @@ nsObjectLoadingContent::UpdateObjectPara
   // that far.
   nsObjectLoadingContent::ParameterUpdateFlags retval = eParamNoChange;
 
   ///
   /// Initial MIME Type
   ///
 
   if (aJavaURI || thisContent->NodeInfo()->Equals(nsGkAtoms::applet)) {
-    Preferences::GetCString(kPrefJavaMIME, newMime);
+    nsAdoptingCString javaMIME = Preferences::GetCString(kPrefJavaMIME);
+    newMime = javaMIME;
     NS_ASSERTION(IsJavaMIME(newMime),
                  "plugin.mime.java should be recognized as java");
     isJava = true;
   } else {
     nsAutoString rawTypeAttr;
     thisContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type, rawTypeAttr);
     if (!rawTypeAttr.IsEmpty()) {
       typeAttr = rawTypeAttr;
@@ -1682,18 +1682,17 @@ nsObjectLoadingContent::UpdateObjectPara
   /// classID
   ///
 
   if (caps & eSupportClassID) {
     nsAutoString classIDAttr;
     thisContent->GetAttr(kNameSpaceID_None, nsGkAtoms::classid, classIDAttr);
     if (!classIDAttr.IsEmpty()) {
       // Our classid support is limited to 'java:' ids
-      nsAutoCString javaMIME;
-      Preferences::GetCString(kPrefJavaMIME, javaMIME);
+      nsAdoptingCString javaMIME = Preferences::GetCString(kPrefJavaMIME);
       NS_ASSERTION(IsJavaMIME(javaMIME),
                    "plugin.mime.java should be recognized as java");
       RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
       if (StringBeginsWith(classIDAttr, NS_LITERAL_STRING("java:")) &&
           pluginHost &&
           pluginHost->HavePluginForType(javaMIME)) {
         newMime = javaMIME;
         isJava = true;
--- a/dom/base/nsPluginArray.cpp
+++ b/dom/base/nsPluginArray.cpp
@@ -328,19 +328,17 @@ operator<(const RefPtr<nsPluginElement>&
 {
   // Sort plugins alphabetically by name.
   return lhs->PluginTag()->Name() < rhs->PluginTag()->Name();
 }
 
 static bool
 PluginShouldBeHidden(const nsCString& aName) {
   // This only supports one hidden plugin
-  nsAutoCString value;
-  Preferences::GetCString("plugins.navigator.hidden_ctp_plugin", value);
-  return value.Equals(aName);
+  return Preferences::GetCString("plugins.navigator.hidden_ctp_plugin").Equals(aName);
 }
 
 void
 nsPluginArray::EnsurePlugins()
 {
   if (!mPlugins.IsEmpty() || !mCTPPlugins.IsEmpty()) {
     // We already have an array of plugin elements.
     return;
--- a/dom/encoding/FallbackEncoding.cpp
+++ b/dom/encoding/FallbackEncoding.cpp
@@ -44,18 +44,18 @@ FallbackEncoding::FallbackEncoding()
 
 NotNull<const Encoding*>
 FallbackEncoding::Get()
 {
   if (mFallback) {
     return WrapNotNull(mFallback);
   }
 
-  nsAutoCString override;
-  Preferences::GetCString("intl.charset.fallback.override", override);
+  const nsAdoptingCString& override =
+    Preferences::GetCString("intl.charset.fallback.override");
   // Don't let the user break things by setting the override to unreasonable
   // values via about:config
   auto encoding = Encoding::ForLabel(override);
   if (!encoding || !encoding->IsAsciiCompatible() ||
       encoding == UTF_8_ENCODING) {
     mFallback = nullptr;
   } else {
     mFallback = encoding;
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -895,18 +895,17 @@ Event::GetEventPopupControlState(WidgetE
 // static
 void
 Event::PopupAllowedEventsChanged()
 {
   if (sPopupAllowedEvents) {
     free(sPopupAllowedEvents);
   }
 
-  nsAutoCString str;
-  Preferences::GetCString("dom.popup_allowed_events", str);
+  nsAdoptingCString str = Preferences::GetCString("dom.popup_allowed_events");
 
   // We'll want to do this even if str is empty to avoid looking up
   // this pref all the time if it's not set.
   sPopupAllowedEvents = ToNewCString(str);
 }
 
 // static
 void
--- a/dom/indexedDB/IndexedDatabaseManager.cpp
+++ b/dom/indexedDB/IndexedDatabaseManager.cpp
@@ -426,18 +426,18 @@ IndexedDatabaseManager::Init()
 
   Preferences::RegisterCallbackAndCall(DataThresholdPrefChangedCallback,
                                        kDataThresholdPref);
 
   Preferences::RegisterCallbackAndCall(MaxSerializedMsgSizePrefChangeCallback,
                                        kPrefMaxSerilizedMsgSize);
 
 #ifdef ENABLE_INTL_API
-  nsAutoCString acceptLang;
-  Preferences::GetLocalizedCString("intl.accept_languages", acceptLang);
+  const nsAdoptingCString& acceptLang =
+    Preferences::GetLocalizedCString("intl.accept_languages");
 
   // Split values on commas.
   nsCCharSeparatedTokenizer langTokenizer(acceptLang, ',');
   while (langTokenizer.hasMoreTokens()) {
     nsAutoCString lang(langTokenizer.nextToken());
     icu::Locale locale = icu::Locale::createCanonical(lang.get());
     if (!locale.isBogus()) {
       // icu::Locale::getBaseName is always ASCII as per BCP 47
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1509,25 +1509,23 @@ StartMacOSContentSandbox()
   info.appPath.assign(appPath.get());
   info.appBinaryPath.assign(appBinaryPath.get());
   info.appDir.assign(appDir.get());
   info.appTempDir.assign(tempDirPath.get());
 
   // These paths are used to whitelist certain directories used by the testing
   // system. They should not be considered a public API, and are only intended
   // for use in automation.
-  nsAutoCString testingReadPath1;
-  Preferences::GetCString("security.sandbox.content.mac.testing_read_path1",
-                          testingReadPath1);
+  nsAdoptingCString testingReadPath1 =
+    Preferences::GetCString("security.sandbox.content.mac.testing_read_path1");
   if (!testingReadPath1.IsEmpty()) {
     info.testingReadPath1.assign(testingReadPath1.get());
   }
-  nsAutoCString testingReadPath2;
-  Preferences::GetCString("security.sandbox.content.mac.testing_read_path2",
-                          testingReadPath2);
+  nsAdoptingCString testingReadPath2 =
+    Preferences::GetCString("security.sandbox.content.mac.testing_read_path2");
   if (!testingReadPath2.IsEmpty()) {
     info.testingReadPath2.assign(testingReadPath2.get());
   }
 
   if (mozilla::IsDevelopmentBuild()) {
     nsCOMPtr<nsIFile> repoDir;
     rv = mozilla::GetRepoDir(getter_AddRefs(repoDir));
     if (NS_FAILED(rv)) {
@@ -1605,22 +1603,21 @@ ContentChild::RecvSetProcessSandbox(cons
       brokerFd = fd.release();
       // brokerFd < 0 means to allow direct filesystem access, so
       // make absolutely sure that doesn't happen if the parent
       // didn't intend it.
       MOZ_RELEASE_ASSERT(brokerFd >= 0);
     }
     // Allow user overrides of seccomp-bpf syscall filtering
     std::vector<int> syscallWhitelist;
-    nsAutoCString extraSyscalls;
-    nsresult rv =
-      Preferences::GetCString("security.sandbox.content.syscall_whitelist",
-                              extraSyscalls);
-    if (NS_SUCCEEDED(rv)) {
+    nsAdoptingCString extraSyscalls =
+      Preferences::GetCString("security.sandbox.content.syscall_whitelist");
+    if (extraSyscalls) {
       for (const nsACString& callNrString : extraSyscalls.Split(',')) {
+        nsresult rv;
         int callNr = PromiseFlatCString(callNrString).ToInteger(&rv);
         if (NS_SUCCEEDED(rv)) {
           syscallWhitelist.push_back(callNr);
         }
       }
     }
     ContentChild* cc = ContentChild::GetSingleton();
     bool isFileProcess = cc->GetRemoteType().EqualsLiteral(FILE_REMOTE_TYPE);
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2035,18 +2035,17 @@ ContentParent::LaunchSubprocess(ProcessP
     switch (Preferences::GetType(ContentPrefs::GetContentPref(i))) {
     case nsIPrefBranch::PREF_INT:
       intPrefs.Append(nsPrintfCString("%u:%d|", i, Preferences::GetInt(ContentPrefs::GetContentPref(i))));
       break;
     case nsIPrefBranch::PREF_BOOL:
       boolPrefs.Append(nsPrintfCString("%u:%d|", i, Preferences::GetBool(ContentPrefs::GetContentPref(i))));
       break;
     case nsIPrefBranch::PREF_STRING: {
-      nsAutoCString value;
-      Preferences::GetCString(ContentPrefs::GetContentPref(i), value);
+      nsAdoptingCString value(Preferences::GetCString(ContentPrefs::GetContentPref(i)));
       stringPrefs.Append(nsPrintfCString("%u:%d;%s|", i, value.Length(), value.get()));
 
     }
       break;
     case nsIPrefBranch::PREF_INVALID:
       break;
     default:
       printf("preference type: %x\n", Preferences::GetType(ContentPrefs::GetContentPref(i)));
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -399,18 +399,18 @@ static bool
 AllowNotification(const NotificationAndReportStringId& aNotification)
 {
   // "media.decoder-doctor.notifications-allowed" controls which notifications
   // may be dispatched to the front-end. It either contains:
   // - '*' -> Allow everything.
   // - Comma-separater list of ids -> Allow if aReportStringId (from
   //                                  dom.properties) is one of them.
   // - Nothing (missing or empty) -> Disable everything.
-  nsAutoCString filter;
-  Preferences::GetCString("media.decoder-doctor.notifications-allowed", filter);
+  nsAdoptingCString filter =
+    Preferences::GetCString("media.decoder-doctor.notifications-allowed");
   return filter.EqualsLiteral("*") ||
          StringListContains(filter, aNotification.mReportStringId);
 }
 
 static bool
 AllowDecodeIssue(const MediaResult& aDecodeIssue, bool aDecodeIssueIsError)
 {
   if (aDecodeIssue == NS_OK) {
@@ -419,21 +419,20 @@ AllowDecodeIssue(const MediaResult& aDec
     return true;
   }
 
   // "media.decoder-doctor.decode-{errors,warnings}-allowed" controls which
   // decode issues may be dispatched to the front-end. It either contains:
   // - '*' -> Allow everything.
   // - Comma-separater list of ids -> Allow if the issue name is one of them.
   // - Nothing (missing or empty) -> Disable everything.
-  nsAutoCString filter;
-  Preferences::GetCString(aDecodeIssueIsError
-                          ? "media.decoder-doctor.decode-errors-allowed"
-                          : "media.decoder-doctor.decode-warnings-allowed",
-                          filter);
+  nsAdoptingCString filter =
+    Preferences::GetCString(aDecodeIssueIsError
+                            ? "media.decoder-doctor.decode-errors-allowed"
+                            : "media.decoder-doctor.decode-warnings-allowed");
   if (filter.EqualsLiteral("*")) {
     return true;
   }
 
   nsCString decodeIssueName;
   GetErrorName(aDecodeIssue.Code(), static_cast<nsACString&>(decodeIssueName));
   return StringListContains(filter, decodeIssueName);
 }
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1694,26 +1694,26 @@ MediaManager::EnumerateRawDevices(uint64
                                   bool aFake)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aVideoType != MediaSourceEnum::Other ||
              aAudioType != MediaSourceEnum::Other);
   RefPtr<PledgeSourceSet> p = new PledgeSourceSet();
   uint32_t id = mOutstandingPledges.Append(*p);
 
-  nsAutoCString audioLoopDev, videoLoopDev;
+  nsAdoptingCString audioLoopDev, videoLoopDev;
   if (!aFake) {
     // Fake stream not requested. The entire device stack is available.
     // Loop in loopback devices if they are set, and their respective type is
     // requested. This is currently used for automated media tests only.
     if (aVideoType == MediaSourceEnum::Camera) {
-      Preferences::GetCString("media.video_loopback_dev", videoLoopDev);
+      videoLoopDev = Preferences::GetCString("media.video_loopback_dev");
     }
     if (aAudioType == MediaSourceEnum::Microphone) {
-      Preferences::GetCString("media.audio_loopback_dev", audioLoopDev);
+      audioLoopDev = Preferences::GetCString("media.audio_loopback_dev");
     }
   }
 
   RefPtr<Runnable> task = NewTaskFrom([id, aWindowId, audioLoopDev,
                                        videoLoopDev, aVideoType,
                                        aAudioType, aFake]() mutable {
     // Only enumerate what's asked for, and only fake cams and mics.
     bool hasVideo = aVideoType != MediaSourceEnum::Other;
@@ -1730,27 +1730,25 @@ MediaManager::EnumerateRawDevices(uint64
       realBackend = manager->GetBackend(aWindowId);
     }
 
     auto result = MakeUnique<SourceSet>();
 
     if (hasVideo) {
       nsTArray<RefPtr<VideoDevice>> videos;
       GetSources(fakeCams? fakeBackend : realBackend, aVideoType,
-                 &MediaEngine::EnumerateVideoDevices, videos,
-                 videoLoopDev.get());
+                 &MediaEngine::EnumerateVideoDevices, videos, videoLoopDev);
       for (auto& source : videos) {
         result->AppendElement(source);
       }
     }
     if (hasAudio) {
       nsTArray<RefPtr<AudioDevice>> audios;
       GetSources(fakeMics? fakeBackend : realBackend, aAudioType,
-                 &MediaEngine::EnumerateAudioDevices, audios,
-                 audioLoopDev.get());
+                 &MediaEngine::EnumerateAudioDevices, audios, audioLoopDev);
       for (auto& source : audios) {
         result->AppendElement(source);
       }
     }
     SourceSet* handoff = result.release();
     NS_DispatchToMainThread(NewRunnableFrom([id, handoff]() mutable {
       UniquePtr<SourceSet> result(handoff); // grab result
       RefPtr<MediaManager> mgr = MediaManager_GetInstance();
--- a/dom/media/webspeech/recognition/SpeechRecognition.cpp
+++ b/dom/media/webspeech/recognition/SpeechRecognition.cpp
@@ -67,18 +67,18 @@ GetSpeechRecognitionLog()
 }
 #define SR_LOG(...) MOZ_LOG(GetSpeechRecognitionLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
 
 already_AddRefed<nsISpeechRecognitionService>
 GetSpeechRecognitionService(const nsAString& aLang)
 {
   nsAutoCString speechRecognitionServiceCID;
 
-  nsAutoCString prefValue;
-  Preferences::GetCString(PREFERENCE_DEFAULT_RECOGNITION_SERVICE, prefValue);
+  nsAdoptingCString prefValue =
+    Preferences::GetCString(PREFERENCE_DEFAULT_RECOGNITION_SERVICE);
   nsAutoCString speechRecognitionService;
 
   if (!aLang.IsEmpty()) {
     speechRecognitionService =
       NS_LITERAL_CSTRING(DEFAULT_RECOGNITION_SERVICE_PREFIX) +
       NS_ConvertUTF16toUTF8(aLang);
   } else if (!prefValue.IsEmpty()) {
     speechRecognitionService = prefValue;
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -1549,18 +1549,18 @@ nsPluginHost::RegisterFakePlugin(JS::Han
   for (const auto& existingTag : mFakePlugins) {
     if (newTag->HandlerURIMatches(existingTag->HandlerURI())) {
       return NS_ERROR_UNEXPECTED;
     }
   }
 
   mFakePlugins.AppendElement(newTag);
 
-  nsAutoCString disableFullPage;
-  Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
+  nsAdoptingCString disableFullPage =
+    Preferences::GetCString(kPrefDisableFullPage);
   for (uint32_t i = 0; i < newTag->MimeTypes().Length(); i++) {
     if (!IsTypeInList(newTag->MimeTypes()[i], disableFullPage)) {
       RegisterWithCategoryManager(newTag->MimeTypes()[i],
                                   ePluginRegister);
     }
   }
 
   newTag.forget(aResult);
@@ -1817,19 +1817,18 @@ nsPluginHost::GetSpecialType(const nsACS
   }
 
   // Java registers variants of its MIME with parameters, e.g.
   // application/x-java-vm;version=1.3
   const nsACString &noParam = Substring(aMIMEType, 0, aMIMEType.FindChar(';'));
 
   // The java mime pref may well not be one of these,
   // e.g. application/x-java-test used in the test suite
-  nsAutoCString javaMIME;
-  Preferences::GetCString(kPrefJavaMIME, javaMIME);
-  if ((!javaMIME.IsEmpty() && noParam.LowerCaseEqualsASCII(javaMIME.get())) ||
+  nsAdoptingCString javaMIME = Preferences::GetCString(kPrefJavaMIME);
+  if ((!javaMIME.IsEmpty() && noParam.LowerCaseEqualsASCII(javaMIME)) ||
       noParam.LowerCaseEqualsASCII("application/x-java-vm") ||
       noParam.LowerCaseEqualsASCII("application/x-java-applet") ||
       noParam.LowerCaseEqualsASCII("application/x-java-bean")) {
     return eSpecialType_Java;
   }
 
   return eSpecialType_None;
 }
@@ -2009,18 +2008,18 @@ ShouldAddPlugin(const nsPluginInfo& info
 
 void
 nsPluginHost::AddPluginTag(nsPluginTag* aPluginTag)
 {
   aPluginTag->mNext = mPlugins;
   mPlugins = aPluginTag;
 
   if (aPluginTag->IsActive()) {
-    nsAutoCString disableFullPage;
-    Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
+    nsAdoptingCString disableFullPage =
+      Preferences::GetCString(kPrefDisableFullPage);
     for (uint32_t i = 0; i < aPluginTag->MimeTypes().Length(); i++) {
       if (!IsTypeInList(aPluginTag->MimeTypes()[i], disableFullPage)) {
         RegisterWithCategoryManager(aPluginTag->MimeTypes()[i],
                                     ePluginRegister);
       }
     }
   }
 }
@@ -2403,18 +2402,18 @@ nsPluginHost::SetPluginsInContent(uint32
                                                       mozilla::ipc::DeserializeURI(tag.handlerURI()),
                                                       tag.name().get(),
                                                       tag.description().get(),
                                                       tag.mimeTypes(),
                                                       tag.mimeDescriptions(),
                                                       tag.extensions(),
                                                       tag.niceName(),
                                                       tag.sandboxScript()));
-      nsAutoCString disableFullPage;
-      Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
+      nsAdoptingCString disableFullPage =
+        Preferences::GetCString(kPrefDisableFullPage);
       for (uint32_t i = 0; i < pluginTag->MimeTypes().Length(); i++) {
         if (!IsTypeInList(pluginTag->MimeTypes()[i], disableFullPage)) {
           RegisterWithCategoryManager(pluginTag->MimeTypes()[i],
                                       ePluginRegister);
         }
       }
     }
 
@@ -2651,18 +2650,18 @@ nsPluginHost::UpdateInMemoryPluginInfo(n
   NS_ITERATIVE_UNREF_LIST(RefPtr<nsPluginTag>, mCachedPlugins, mNext);
   NS_ITERATIVE_UNREF_LIST(RefPtr<nsInvalidPluginTag>, mInvalidPlugins, mNext);
 
   if (!aPluginTag) {
     return;
   }
 
   // Update types with category manager
-  nsAutoCString disableFullPage;
-  Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
+  nsAdoptingCString disableFullPage =
+    Preferences::GetCString(kPrefDisableFullPage);
   for (uint32_t i = 0; i < aPluginTag->MimeTypes().Length(); i++) {
     nsRegisterType shouldRegister;
 
     if (IsTypeInList(aPluginTag->MimeTypes()[i], disableFullPage)) {
       shouldRegister = ePluginUnregister;
     } else {
       nsPluginTag *plugin = FindNativePluginForType(aPluginTag->MimeTypes()[i],
                                                     true);
@@ -2690,19 +2689,18 @@ nsPluginHost::UpdatePluginInfo(nsPluginT
   IncrementChromeEpoch();
 
   UpdateInMemoryPluginInfo(aPluginTag);
 }
 
 /* static */ bool
 nsPluginHost::IsTypeWhitelisted(const char *aMimeType)
 {
-  nsAutoCString whitelist;
-  Preferences::GetCString(kPrefWhitelist, whitelist);
-  if (whitelist.IsEmpty()) {
+  nsAdoptingCString whitelist = Preferences::GetCString(kPrefWhitelist);
+  if (!whitelist.Length()) {
     return true;
   }
   nsDependentCString wrap(aMimeType);
   return IsTypeInList(wrap, whitelist);
 }
 
 /* static */ bool
 nsPluginHost::ShouldLoadTypeInParent(const nsACString& aMimeType)
--- a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
+++ b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
@@ -155,17 +155,17 @@ MulticastDNSDeviceProvider::Init()
   }
   Preferences::AddStrongObservers(this, kObservedPrefs);
 
   mDiscoveryEnabled = Preferences::GetBool(PREF_PRESENTATION_DISCOVERY);
   mDiscoveryTimeoutMs = Preferences::GetUint(PREF_PRESENTATION_DISCOVERY_TIMEOUT_MS);
   mDiscoverable = Preferences::GetBool(PREF_PRESENTATION_DISCOVERABLE);
   mDiscoverableEncrypted = Preferences::GetBool(PREF_PRESENTATION_DISCOVERABLE_ENCRYPTED);
   mServerRetryMs = Preferences::GetUint(PREF_PRESENTATION_DISCOVERABLE_RETRY_MS);
-  Preferences::GetCString(PREF_PRESENTATION_DEVICE_NAME, mServiceName);
+  mServiceName = Preferences::GetCString(PREF_PRESENTATION_DEVICE_NAME);
 
 #ifdef MOZ_WIDGET_ANDROID
   // FIXME: Bug 1185806 - Provide a common device name setting.
   if (mServiceName.IsEmpty()) {
     GetAndroidDeviceName(mServiceName);
     Unused << Preferences::SetCString(PREF_PRESENTATION_DEVICE_NAME, mServiceName);
   }
 #endif // MOZ_WIDGET_ANDROID
@@ -1093,18 +1093,17 @@ MulticastDNSDeviceProvider::Observe(nsIS
   if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
     if (data.EqualsLiteral(PREF_PRESENTATION_DISCOVERY)) {
       OnDiscoveryChanged(Preferences::GetBool(PREF_PRESENTATION_DISCOVERY));
     } else if (data.EqualsLiteral(PREF_PRESENTATION_DISCOVERY_TIMEOUT_MS)) {
       OnDiscoveryTimeoutChanged(Preferences::GetUint(PREF_PRESENTATION_DISCOVERY_TIMEOUT_MS));
     } else if (data.EqualsLiteral(PREF_PRESENTATION_DISCOVERABLE)) {
       OnDiscoverableChanged(Preferences::GetBool(PREF_PRESENTATION_DISCOVERABLE));
     } else if (data.EqualsLiteral(PREF_PRESENTATION_DEVICE_NAME)) {
-      nsAutoCString newServiceName;
-      Preferences::GetCString(PREF_PRESENTATION_DEVICE_NAME, newServiceName);
+      nsAdoptingCString newServiceName = Preferences::GetCString(PREF_PRESENTATION_DEVICE_NAME);
       if (!mServiceName.Equals(newServiceName)) {
         OnServiceNameChanged(newServiceName);
       }
     }
   } else if (!strcmp(aTopic, NS_TIMER_CALLBACK_TOPIC)) {
     nsCOMPtr<nsITimer> timer = do_QueryInterface(aSubject);
     if (!timer) {
       return NS_ERROR_UNEXPECTED;
--- a/dom/security/nsContentSecurityManager.cpp
+++ b/dom/security/nsContentSecurityManager.cpp
@@ -709,20 +709,18 @@ nsContentSecurityManager::IsOriginPotent
     return NS_OK;
   }
 
   // If a host is not considered secure according to the default algorithm, then
   // check to see if it has been whitelisted by the user.  We only apply this
   // whitelist for network resources, i.e., those with scheme "http" or "ws".
   // The pref should contain a comma-separated list of hostnames.
   if (scheme.EqualsLiteral("http") || scheme.EqualsLiteral("ws")) {
-    nsAutoCString whitelist;
-    nsresult rv =
-      Preferences::GetCString("dom.securecontext.whitelist", whitelist);
-    if (NS_SUCCEEDED(rv)) {
+    nsAdoptingCString whitelist = Preferences::GetCString("dom.securecontext.whitelist");
+    if (whitelist) {
       nsCCharSeparatedTokenizer tokenizer(whitelist, ',');
       while (tokenizer.hasMoreTokens()) {
         const nsACString& allowedHost = tokenizer.nextToken();
         if (host.Equals(allowedHost)) {
           *aIsTrustWorthy = true;
           return NS_OK;
         }
       }
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -271,18 +271,18 @@ HTMLEditRules::Init(TextEditor* aTextEdi
 
   // call through to base class Init
   nsresult rv = TextEditRules::Init(aTextEditor);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // cache any prefs we care about
   static const char kPrefName[] =
     "editor.html.typing.returnInEmptyListItemClosesList";
-  nsAutoCString returnInEmptyLIKillsList;
-  Preferences::GetCString(kPrefName, returnInEmptyLIKillsList);
+  nsAdoptingCString returnInEmptyLIKillsList =
+    Preferences::GetCString(kPrefName);
 
   // only when "false", becomes FALSE.  Otherwise (including empty), TRUE.
   // XXX Why was this pref designed as a string and not bool?
   mReturnInEmptyLIKillsList = !returnInEmptyLIKillsList.EqualsLiteral("false");
 
   // make a utility range for use by the listenter
   nsCOMPtr<nsINode> node = mHTMLEditor->GetRoot();
   if (!node) {
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -2852,18 +2852,17 @@ nsPermissionManager::Import()
   return NS_OK;
 }
 
 // ImportDefaults will read a URL with default permissions and add them to the
 // in-memory copy of permissions.  The database is *not* written to.
 nsresult
 nsPermissionManager::ImportDefaults()
 {
-  nsAutoCString defaultsURL;
-  mozilla::Preferences::GetCString(kDefaultsUrlPrefName, defaultsURL);
+  nsCString defaultsURL = mozilla::Preferences::GetCString(kDefaultsUrlPrefName);
   if (defaultsURL.IsEmpty()) { // == Don't use built-in permissions.
     return NS_OK;
   }
 
   nsCOMPtr<nsIURI> defaultsURI;
   nsresult rv = NS_NewURI(getter_AddRefs(defaultsURI), defaultsURL);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -73,18 +73,18 @@ static PRLibrary* LoadApitraceLibrary()
         return nullptr;
     }
 
     static PRLibrary* sApitraceLibrary = nullptr;
 
     if (sApitraceLibrary)
         return sApitraceLibrary;
 
-    nsAutoCString logFile;
-    Preferences::GetCString("gfx.apitrace.logfile", logFile);
+    nsCString logFile = Preferences::GetCString("gfx.apitrace.logfile");
+
     if (logFile.IsEmpty()) {
         logFile = "firefox.trace";
     }
 
     // The firefox process can't write to /data/local, but it can write
     // to $GRE_HOME/
     nsAutoCString logPath;
     logPath.AppendPrintf("%s/%s", getenv("GRE_HOME"), logFile.get());
--- a/gfx/thebes/gfxDWriteFontList.cpp
+++ b/gfx/thebes/gfxDWriteFontList.cpp
@@ -986,21 +986,19 @@ gfxDWriteFontList::InitFontListForPlatfo
                 }
             }
 
             // remove Gills Sans
             mFontFamilies.Remove(nameGillSans);
         }
     }
 
-    nsAutoCString classicFamilies;
-    nsresult rv = Preferences::GetCString(
-      "gfx.font_rendering.cleartype_params.force_gdi_classic_for_families",
-      classicFamilies);
-    if (NS_SUCCEEDED(rv)) {
+    nsAdoptingCString classicFamilies =
+        Preferences::GetCString("gfx.font_rendering.cleartype_params.force_gdi_classic_for_families");
+    if (classicFamilies) {
         nsCCharSeparatedTokenizer tokenizer(classicFamilies, ',');
         while (tokenizer.hasMoreTokens()) {
             NS_ConvertUTF8toUTF16 name(tokenizer.nextToken());
             BuildKeyNameFromFontName(name);
             gfxFontFamily *family = mFontFamilies.GetWeak(name);
             if (family) {
                 static_cast<gfxDWriteFontFamily*>(family)->SetForceGDIClassic(true);
             }
--- a/gfx/thebes/gfxFcPlatformFontList.cpp
+++ b/gfx/thebes/gfxFcPlatformFontList.cpp
@@ -1897,25 +1897,25 @@ gfxFcPlatformFontList::PrefFontListsUseO
             //       font.name-list.serif.ar ==> "Something, serif"
             //                                           (return false)
 
             nsDependentCString prefName(names[i] +
                                         ArrayLength(kFontNamePrefix) - 1);
             nsCCharSeparatedTokenizer tokenizer(prefName, '.');
             const nsDependentCSubstring& generic = tokenizer.nextToken();
             const nsDependentCSubstring& langGroup = tokenizer.nextToken();
-            nsAutoCString fontPrefValue;
-            Preferences::GetCString(names[i], fontPrefValue);
+            nsAdoptingCString fontPrefValue = Preferences::GetCString(names[i]);
             if (fontPrefValue.IsEmpty()) {
                 // The font name list may have two or more family names as comma
                 // separated list.  In such case, not matching with generic font
                 // name is fine because if the list prefers specific font, this
                 // should return false.
-                Preferences::GetCString(NameListPref(generic, langGroup).get(),
-                                        fontPrefValue);
+                fontPrefValue =
+                    Preferences::GetCString(NameListPref(generic,
+                                                         langGroup).get());
             }
 
             if (!langGroup.EqualsLiteral("x-math") &&
                 !generic.Equals(fontPrefValue)) {
                 prefFontsUseOnlyGenerics = false;
                 break;
             }
         }
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -640,22 +640,18 @@ gfxPlatform::Init()
 
     if (XRE_IsParentProcess()) {
       GPUProcessManager::Initialize();
 
       if (Preferences::GetBool("media.wmf.skip-blacklist")) {
         gfxVars::SetPDMWMFDisableD3D11Dlls(nsCString());
         gfxVars::SetPDMWMFDisableD3D9Dlls(nsCString());
       } else {
-        nsAutoCString d3d11;
-        Preferences::GetCString("media.wmf.disable-d3d11-for-dlls", d3d11);
-        gfxVars::SetPDMWMFDisableD3D11Dlls(d3d11);
-        nsAutoCString d3d9;
-        Preferences::GetCString("media.wmf.disable-d3d9-for-dlls", d3d9);
-        gfxVars::SetPDMWMFDisableD3D9Dlls(d3d9);
+        gfxVars::SetPDMWMFDisableD3D11Dlls(Preferences::GetCString("media.wmf.disable-d3d11-for-dlls"));
+        gfxVars::SetPDMWMFDisableD3D9Dlls(Preferences::GetCString("media.wmf.disable-d3d9-for-dlls"));
       }
 
       nsCOMPtr<nsIFile> file;
       nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(file));
       if (NS_FAILED(rv)) {
         gfxVars::SetGREDirectory(nsCString());
       } else {
         nsAutoCString nativePath;
@@ -1941,20 +1937,19 @@ gfxPlatform::GetPlatformCMSOutputProfile
 {
     mem = nullptr;
     size = 0;
 }
 
 void
 gfxPlatform::GetCMSOutputProfileData(void *&mem, size_t &size)
 {
-    nsAutoCString fname;
-    Preferences::GetCString("gfx.color_management.display_profile", fname);
+    nsAdoptingCString fname = Preferences::GetCString("gfx.color_management.display_profile");
     if (!fname.IsEmpty()) {
-        qcms_data_from_path(fname.get(), &mem, &size);
+        qcms_data_from_path(fname, &mem, &size);
     }
     else {
         gfxPlatform::GetPlatform()->GetPlatformCMSOutputProfile(mem, size);
     }
 }
 
 void
 gfxPlatform::CreateCMSOutputProfile()
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -1084,18 +1084,17 @@ gfxPlatformFontList::AppendCJKPrefLangs(
     // if not set up, set up the default CJK order, based on accept lang settings and locale
     if (mCJKPrefLangs.Length() == 0) {
 
         // temp array
         eFontPrefLang tempPrefLangs[kMaxLenPrefLangList];
         uint32_t tempLen = 0;
 
         // Add the CJK pref fonts from accept languages, the order should be same order
-        nsAutoCString list;
-        Preferences::GetLocalizedCString("intl.accept_languages", list);
+        nsAdoptingCString list = Preferences::GetLocalizedCString("intl.accept_languages");
         if (!list.IsEmpty()) {
             const char kComma = ',';
             const char *p, *p_end;
             list.BeginReading(p);
             list.EndReading(p_end);
             while (p < p_end) {
                 while (nsCRT::IsAsciiSpace(*p)) {
                     if (++p == p_end)
@@ -1211,18 +1210,18 @@ mozilla::FontFamilyType
 gfxPlatformFontList::GetDefaultGeneric(eFontPrefLang aLang)
 {
     // initialize lang group pref font defaults (i.e. serif/sans-serif)
     if (MOZ_UNLIKELY(mDefaultGenericsLangGroup.IsEmpty())) {
         mDefaultGenericsLangGroup.AppendElements(ArrayLength(gPrefLangNames));
         for (uint32_t i = 0; i < ArrayLength(gPrefLangNames); i++) {
             nsAutoCString prefDefaultFontType("font.default.");
             prefDefaultFontType.Append(GetPrefLangName(eFontPrefLang(i)));
-            nsAutoCString serifOrSans;
-            Preferences::GetCString(prefDefaultFontType.get(), serifOrSans);
+            nsAdoptingCString serifOrSans =
+                Preferences::GetCString(prefDefaultFontType.get());
             if (serifOrSans.EqualsLiteral("sans-serif")) {
                 mDefaultGenericsLangGroup[i] = eFamily_sans_serif;
             } else {
                 mDefaultGenericsLangGroup[i] = eFamily_serif;
             }
         }
     }
 
--- a/gfx/vr/gfxVROSVR.cpp
+++ b/gfx/vr/gfxVROSVR.cpp
@@ -110,26 +110,28 @@ static pfn_osvrClientSetRoomRotationUsin
 bool
 LoadOSVRRuntime()
 {
   static PRLibrary* osvrUtilLib = nullptr;
   static PRLibrary* osvrCommonLib = nullptr;
   static PRLibrary* osvrClientLib = nullptr;
   static PRLibrary* osvrClientKitLib = nullptr;
   //this looks up the path in the about:config setting, from greprefs.js or modules\libpref\init\all.js
+  nsAdoptingCString osvrUtilPath =
+    mozilla::Preferences::GetCString("gfx.vr.osvr.utilLibPath");
+  nsAdoptingCString osvrCommonPath =
+    mozilla::Preferences::GetCString("gfx.vr.osvr.commonLibPath");
+  nsAdoptingCString osvrClientPath =
+    mozilla::Preferences::GetCString("gfx.vr.osvr.clientLibPath");
+  nsAdoptingCString osvrClientKitPath =
+    mozilla::Preferences::GetCString("gfx.vr.osvr.clientKitLibPath");
+
   //we need all the libs to be valid
-  nsAutoCString osvrUtilPath, osvrCommonPath, osvrClientPath, osvrClientKitPath;
-  if (NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.utilLibPath",
-                                                 osvrUtilPath)) ||
-      NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.commonLibPath",
-                                                 osvrCommonPath)) ||
-      NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.clientLibPath",
-                                                 osvrClientPath)) ||
-      NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.clientKitLibPath",
-                                                 osvrClientKitPath))) {
+  if ((!osvrUtilPath) || (!osvrCommonPath) || (!osvrClientPath) ||
+      (!osvrClientKitPath)) {
     return false;
   }
 
   osvrUtilLib = PR_LoadLibrary(osvrUtilPath.BeginReading());
   osvrCommonLib = PR_LoadLibrary(osvrCommonPath.BeginReading());
   osvrClientLib = PR_LoadLibrary(osvrClientPath.BeginReading());
   osvrClientKitLib = PR_LoadLibrary(osvrClientKitPath.BeginReading());
 
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -1339,23 +1339,22 @@ imgLoader::Observe(nsISupports* aSubject
     MOZ_ASSERT(0, "Invalid topic received");
   }
 
   return NS_OK;
 }
 
 void imgLoader::ReadAcceptHeaderPref()
 {
-  nsAutoCString accept;
-  nsresult rv = Preferences::GetCString("image.http.accept", accept);
-  if (NS_SUCCEEDED(rv)) {
+  nsAdoptingCString accept = Preferences::GetCString("image.http.accept");
+  if (accept) {
     mAcceptHeader = accept;
   } else {
     mAcceptHeader =
-      IMAGE_PNG "," IMAGE_WILDCARD ";q=0.8," ANY_WILDCARD ";q=0.5";
+        IMAGE_PNG "," IMAGE_WILDCARD ";q=0.8," ANY_WILDCARD ";q=0.5";
   }
 }
 
 NS_IMETHODIMP
 imgLoader::ClearCache(bool chrome)
 {
   if (XRE_IsParentProcess()) {
     bool privateLoader = this == gPrivateBrowsingLoader;
--- a/intl/hyphenation/glue/nsHyphenationManager.cpp
+++ b/intl/hyphenation/glue/nsHyphenationManager.cpp
@@ -300,19 +300,18 @@ nsHyphenationManager::LoadAliases()
     return;
   }
   uint32_t prefCount;
   char **prefNames;
   nsresult rv = prefRootBranch->GetChildList(kIntlHyphenationAliasPrefix,
                                              &prefCount, &prefNames);
   if (NS_SUCCEEDED(rv) && prefCount > 0) {
     for (uint32_t i = 0; i < prefCount; ++i) {
-      nsAutoCString value;
-      rv = Preferences::GetCString(prefNames[i], value);
-      if (NS_SUCCEEDED(rv)) {
+      nsAdoptingCString value = Preferences::GetCString(prefNames[i]);
+      if (value) {
         nsAutoCString alias(prefNames[i]);
         alias.Cut(0, sizeof(kIntlHyphenationAliasPrefix) - 1);
         ToLowerCase(alias);
         ToLowerCase(value);
         nsCOMPtr<nsIAtom> aliasAtom = NS_Atomize(alias);
         nsCOMPtr<nsIAtom> valueAtom = NS_Atomize(value);
         mHyphAliases.Put(aliasAtom, valueAtom);
       }
--- a/intl/locale/android/OSPreferences_android.cpp
+++ b/intl/locale/android/OSPreferences_android.cpp
@@ -14,18 +14,17 @@ OSPreferences::ReadSystemLocales(nsTArra
 {
   //XXX: This is a quite sizable hack to work around the fact that we cannot
   //     retrieve OS locale in C++ without reaching out to JNI.
   //     Once we fix this (bug 1337078), this hack should not be necessary.
   //
   //XXX: Notice, this value may be empty on an early read. In that case
   //     we won't add anything to the return list so that it doesn't get
   //     cached in mSystemLocales.
-  nsAutoCString locale;
-  Preferences::GetCString("intl.locale.os", locale);
+  nsAdoptingCString locale = Preferences::GetCString("intl.locale.os");
   if (!locale.IsEmpty()) {
     aLocaleList.AppendElement(locale);
     return true;
   }
   return false;
 }
 
 bool
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -68,21 +68,19 @@ ForbidUnsafeBrowserCPOWs()
 static bool
 ForbidCPOWsInCompatibleAddon(const nsACString& aAddonId)
 {
     bool forbid = Preferences::GetBool("dom.ipc.cpows.forbid-cpows-in-compat-addons", false);
     if (!forbid) {
         return false;
     }
 
-    nsAutoCString allow;
+    nsCString allow;
     allow.Assign(',');
-    nsAutoCString pref;
-    Preferences::GetCString("dom.ipc.cpows.allow-cpows-in-compat-addons", pref);
-    allow.Append(pref);
+    allow.Append(Preferences::GetCString("dom.ipc.cpows.allow-cpows-in-compat-addons"));
     allow.Append(',');
 
     nsCString searchString(",");
     searchString.Append(aAddonId);
     searchString.Append(',');
     return allow.Find(searchString) == kNotFound;
 }
 
--- a/layout/base/StaticPresData.cpp
+++ b/layout/base/StaticPresData.cpp
@@ -98,18 +98,18 @@ LangGroupFontPrefs::Initialize(nsIAtom* 
   mDefaultFixedFont.size = nsPresContext::CSSPixelsToAppUnits(13);
 
   nsAutoCString pref;
 
   // get the current applicable font-size unit
   enum {eUnit_unknown = -1, eUnit_px, eUnit_pt};
   int32_t unit = eUnit_px;
 
-  nsAutoCString cvalue;
-  Preferences::GetCString("font.size.unit", cvalue);
+  nsAdoptingCString cvalue =
+    Preferences::GetCString("font.size.unit");
 
   if (!cvalue.IsEmpty()) {
     if (cvalue.EqualsLiteral("px")) {
       unit = eUnit_px;
     }
     else if (cvalue.EqualsLiteral("pt")) {
       unit = eUnit_pt;
     }
@@ -217,17 +217,17 @@ LangGroupFontPrefs::Initialize(nsIAtom* 
       else if (unit == eUnit_pt) {
         font->size = nsPresContext::CSSPointsToAppUnits(size);
       }
     }
 
     // get font.size-adjust.[generic].[langGroup]
     // XXX only applicable on GFX ports that handle |font-size-adjust|
     MAKE_FONT_PREF_KEY(pref, "font.size-adjust", generic_dot_langGroup);
-    Preferences::GetCString(pref.get(), cvalue);
+    cvalue = Preferences::GetCString(pref.get());
     if (!cvalue.IsEmpty()) {
       font->sizeAdjust = (float)atof(cvalue.get());
     }
 
 #ifdef DEBUG_rbs
     printf("%s Family-list:%s size:%d sizeAdjust:%.2f\n",
            generic_dot_langGroup.get(),
            NS_ConvertUTF16toUTF8(font->name).get(), font->size,
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -631,18 +631,18 @@ nsPresContext::GetUserPreferences()
 
   mPrefScrollbarSide = Preferences::GetInt("layout.scrollbar.side");
 
   mLangGroupFontPrefs.Reset();
   mFontGroupCacheDirty = true;
   StaticPresData::Get()->ResetCachedFontPrefs();
 
   // * image animation
-  nsAutoCString animatePref;
-  Preferences::GetCString("image.animation_mode", animatePref);
+  const nsAdoptingCString& animatePref =
+    Preferences::GetCString("image.animation_mode");
   if (animatePref.EqualsLiteral("normal"))
     mImageAnimationModePref = imgIContainer::kNormalAnimMode;
   else if (animatePref.EqualsLiteral("none"))
     mImageAnimationModePref = imgIContainer::kDontAnimMode;
   else if (animatePref.EqualsLiteral("once"))
     mImageAnimationModePref = imgIContainer::kLoopOnceAnimMode;
   else // dynamic change to invalid value should act like it does initially
     mImageAnimationModePref = imgIContainer::kNormalAnimMode;
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -1600,19 +1600,17 @@ static nsresult pref_InitInitialObjects(
   // channel, telemetry is on by default, otherwise not. This is necessary
   // so that beta users who are testing final release builds don't flipflop
   // defaults.
   if (Preferences::GetDefaultType(kTelemetryPref) == nsIPrefBranch::PREF_INVALID) {
     bool prerelease = false;
 #ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
     prerelease = true;
 #else
-    nsAutoCString prefValue;
-    Preferences::GetDefaultCString(kChannelPref, prefValue);
-    if (prefValue.EqualsLiteral("beta")) {
+    if (Preferences::GetDefaultCString(kChannelPref).EqualsLiteral("beta")) {
       prerelease = true;
     }
 #endif
     PREF_SetBoolPref(kTelemetryPref, prerelease, true);
   }
 
   NS_CreateServicesFromCategory(NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID,
                                 nullptr, NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID);
@@ -1663,24 +1661,33 @@ Preferences::GetFloat(const char* aPref,
   if (NS_SUCCEEDED(rv)) {
     *aResult = result.ToFloat(&rv);
   }
 
   return rv;
 }
 
 // static
+nsAdoptingCString
+Preferences::GetCString(const char* aPref)
+{
+  nsAdoptingCString result;
+  PREF_CopyCharPref(aPref, getter_Copies(result), false);
+  return result;
+}
+
+// static
 nsresult
 Preferences::GetCString(const char* aPref, nsACString& aResult)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  char* result;
-  nsresult rv = PREF_CopyCharPref(aPref, &result, false);
+  nsAutoCString result;
+  nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
   if (NS_SUCCEEDED(rv)) {
-    aResult.Adopt(result);
+    aResult = result;
   }
   return rv;
 }
 
 // static
 nsresult
 Preferences::GetString(const char* aPref, nsAString& aResult)
 {
@@ -1689,16 +1696,25 @@ Preferences::GetString(const char* aPref
   nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
   if (NS_SUCCEEDED(rv)) {
     CopyUTF8toUTF16(result, aResult);
   }
   return rv;
 }
 
 // static
+nsAdoptingCString
+Preferences::GetLocalizedCString(const char* aPref)
+{
+  nsAdoptingCString result;
+  GetLocalizedCString(aPref, result);
+  return result;
+}
+
+// static
 nsresult
 Preferences::GetLocalizedCString(const char* aPref, nsACString& aResult)
 {
   nsAutoString result;
   nsresult rv = GetLocalizedString(aPref, result);
   if (NS_SUCCEEDED(rv)) {
     CopyUTF16toUTF8(result, aResult);
   }
@@ -2158,20 +2174,20 @@ Preferences::GetDefaultInt(const char* a
   return PREF_GetIntPref(aPref, aResult, true);
 }
 
 // static
 nsresult
 Preferences::GetDefaultCString(const char* aPref, nsACString& aResult)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  char* result;
-  nsresult rv = PREF_CopyCharPref(aPref, &result, true);
+  nsAutoCString result;
+  nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), true);
   if (NS_SUCCEEDED(rv)) {
-    aResult.Adopt(result);
+    aResult = result;
   }
   return rv;
 }
 
 // static
 nsresult
 Preferences::GetDefaultString(const char* aPref, nsAString& aResult)
 {
@@ -2211,16 +2227,34 @@ Preferences::GetDefaultLocalizedString(c
   if (NS_SUCCEEDED(rv)) {
     NS_ASSERTION(prefLocalString, "Succeeded but the result is NULL");
     prefLocalString->GetData(getter_Copies(aResult));
   }
   return rv;
 }
 
 // static
+nsAdoptingCString
+Preferences::GetDefaultCString(const char* aPref)
+{
+  nsAdoptingCString result;
+  PREF_CopyCharPref(aPref, getter_Copies(result), true);
+  return result;
+}
+
+// static
+nsAdoptingCString
+Preferences::GetDefaultLocalizedCString(const char* aPref)
+{
+  nsAdoptingCString result;
+  GetDefaultLocalizedCString(aPref, result);
+  return result;
+}
+
+// static
 nsresult
 Preferences::GetDefaultComplex(const char* aPref, const nsIID &aType,
                                void** aResult)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   return sDefaultRootBranch->GetComplexValue(aPref, aType, aResult);
 }
 
--- a/modules/libpref/Preferences.h
+++ b/modules/libpref/Preferences.h
@@ -16,16 +16,17 @@
 #include "nsIObserver.h"
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 #include "nsWeakReference.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/MemoryReporting.h"
 
 class nsIFile;
+class nsAdoptingCString;
 
 #ifndef have_PrefChangedFunc_typedef
 typedef void (*PrefChangedFunc)(const char *, void *);
 #define have_PrefChangedFunc_typedef
 #endif
 
 #ifdef DEBUG
 enum pref_initPhase {
@@ -142,16 +143,40 @@ public:
   static float GetFloat(const char* aPref, float aDefault = 0)
   {
     float result = aDefault;
     GetFloat(aPref, &result);
     return result;
   }
 
   /**
+   * Gets char type pref value directly.  If failed, the get() of result
+   * returns nullptr.  Even if succeeded but the result was empty string, the
+   * get() does NOT return nullptr.  So, you can check whether the method
+   * succeeded or not by:
+   *
+   * nsAdoptingString value = Prefereces::GetString("foo.bar");
+   * if (!value) {
+   *   // failed
+   * }
+   *
+   * Be aware.  If you wrote as:
+   *
+   * nsAutoString value = Preferences::GetString("foo.bar");
+   * if (!value.get()) {
+   *   // the condition is always FALSE!!
+   * }
+   *
+   * The value.get() doesn't return nullptr. You must use nsAdoptingString
+   * when you need to check whether it was failure or not.
+   */
+  static nsAdoptingCString GetCString(const char* aPref);
+  static nsAdoptingCString GetLocalizedCString(const char* aPref);
+
+  /**
    * Gets int, float, or bool type pref value with raw return value of
    * nsIPrefBranch.
    *
    * @param aPref       A pref name.
    * @param aResult     Must not be nullptr.  The value is never modified
    *                    when these methods fail.
    */
   static nsresult GetBool(const char* aPref, bool* aResult);
@@ -348,17 +373,25 @@ public:
   static uint32_t GetDefaultUint(const char* aPref, uint32_t aFailedResult)
   {
    return static_cast<uint32_t>(
      GetDefaultInt(aPref, static_cast<int32_t>(aFailedResult)));
   }
 
   /**
    * Gets the default value of the char type pref.
+   * If the get() of the result returned nullptr, that meant the value didn't
+   * have default value.
+   *
+   * See the comment at definition at GetString() and GetCString() for more
+   * details of the result.
    */
+  static nsAdoptingCString GetDefaultCString(const char* aPref);
+  static nsAdoptingCString GetDefaultLocalizedCString(const char* aPref);
+
   static nsresult GetDefaultCString(const char* aPref, nsACString& aResult);
   static nsresult GetDefaultString(const char* aPref, nsAString& aResult);
   static nsresult GetDefaultLocalizedCString(const char* aPref,
                                              nsACString& aResult);
   static nsresult GetDefaultLocalizedString(const char* aPref,
                                             nsAString& aResult);
 
   static nsresult GetDefaultComplex(const char* aPref, const nsIID &aType,
--- a/netwerk/base/nsChannelClassifier.cpp
+++ b/netwerk/base/nsChannelClassifier.cpp
@@ -115,28 +115,24 @@ StaticAutoPtr<CachedPrefs> CachedPrefs::
 
 // static
 void
 CachedPrefs::OnPrefsChange(const char* aPref, void* aClosure)
 {
   CachedPrefs* prefs = static_cast<CachedPrefs*> (aClosure);
 
   if (!strcmp(aPref, URLCLASSIFIER_SKIP_HOSTNAMES)) {
-    nsCString skipHostnames;
-    Preferences::GetCString(URLCLASSIFIER_SKIP_HOSTNAMES, skipHostnames);
+    nsCString skipHostnames = Preferences::GetCString(URLCLASSIFIER_SKIP_HOSTNAMES);
     ToLowerCase(skipHostnames);
     prefs->SetSkipHostnames(skipHostnames);
   } else if (!strcmp(aPref, URLCLASSIFIER_TRACKING_WHITELIST)) {
-    nsCString trackingWhitelist;
-    Preferences::GetCString(URLCLASSIFIER_TRACKING_WHITELIST,
-                            trackingWhitelist);
+    nsCString trackingWhitelist = Preferences::GetCString(URLCLASSIFIER_TRACKING_WHITELIST);
     prefs->SetTrackingWhiteList(trackingWhitelist);
   } else if (!strcmp(aPref, URLCLASSIFIER_TRACKING_TABLE)) {
-    nsCString trackingBlacklist;
-    Preferences::GetCString(URLCLASSIFIER_TRACKING_TABLE, trackingBlacklist);
+    nsCString trackingBlacklist = Preferences::GetCString(URLCLASSIFIER_TRACKING_TABLE);
     prefs->SetTrackingBlackList(trackingBlacklist);
   }
 }
 
 void
 CachedPrefs::Init()
 {
   Preferences::AddBoolVarCache(&sAnnotateChannelEnabled,
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -1995,18 +1995,18 @@ PrepareAcceptLanguages(const char *i_Acc
     return NS_OK;
 }
 
 nsresult
 nsHttpHandler::SetAcceptLanguages()
 {
     mAcceptLanguagesIsDirty = false;
 
-    nsAutoCString acceptLanguages;
-    Preferences::GetLocalizedCString(INTL_ACCEPT_LANGUAGES, acceptLanguages);
+    const nsAdoptingCString& acceptLanguages =
+        Preferences::GetLocalizedCString(INTL_ACCEPT_LANGUAGES);
 
     nsAutoCString buf;
     nsresult rv = PrepareAcceptLanguages(acceptLanguages.get(), buf);
     if (NS_SUCCEEDED(rv)) {
         mAcceptLanguages.Assign(buf);
     }
     return rv;
 }
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -199,18 +199,18 @@ nsHtml5StreamParser::nsHtml5StreamParser
     mTokenizer->EnableViewSource(highlighter); // takes ownership
     mTreeBuilder->EnableViewSource(highlighter); // doesn't own
   }
 
   // Chardet instantiation adapted from File.
   // Chardet is initialized here even if it turns out to be useless
   // to make the chardet refcount its observer (nsHtml5StreamParser)
   // on the main thread.
-  nsAutoCString detectorName;
-  Preferences::GetLocalizedCString("intl.charset.detector", detectorName);
+  const nsAdoptingCString& detectorName =
+    Preferences::GetLocalizedCString("intl.charset.detector");
   if (!detectorName.IsEmpty()) {
     nsAutoCString detectorContractID;
     detectorContractID.AssignLiteral(NS_CHARSET_DETECTOR_CONTRACTID_BASE);
     detectorContractID += detectorName;
     if ((mChardet = do_CreateInstance(detectorContractID.get()))) {
       (void) mChardet->Init(this);
       mFeedChardet = true;
     }
--- a/security/apps/AppTrustDomain.cpp
+++ b/security/apps/AppTrustDomain.cpp
@@ -80,19 +80,18 @@ AppTrustDomain::SetTrustedRoot(AppTruste
     case nsIX509CertDB::DeveloperImportedRoot: {
       StaticMutexAutoLock lock(sMutex);
       if (!sDevImportedDERData) {
         MOZ_ASSERT(!NS_IsMainThread());
         nsCOMPtr<nsIFile> file(do_CreateInstance("@mozilla.org/file/local;1"));
         if (!file) {
           return NS_ERROR_FAILURE;
         }
-        nsAutoCString path;
-        Preferences::GetCString(kDevImportedDER, path);
-        nsresult rv = file->InitWithNativePath(path);
+        nsresult rv = file->InitWithNativePath(
+          Preferences::GetCString(kDevImportedDER));
         if (NS_FAILED(rv)) {
           return rv;
         }
 
         nsCOMPtr<nsIInputStream> inputStream;
         rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), file, -1,
                                         -1, nsIFileInputStream::CLOSE_ON_EOF);
         if (NS_FAILED(rv)) {
--- a/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
+++ b/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
@@ -230,41 +230,38 @@ SandboxBrokerPolicyFactory::GetContentPo
   policy->AddPath(rdonly, nsPrintfCString("/proc/%d/maps", aPid).get());
 
   // Bug 1198552: memory reporting.
   policy->AddPath(rdonly, nsPrintfCString("/proc/%d/statm", aPid).get());
   policy->AddPath(rdonly, nsPrintfCString("/proc/%d/smaps", aPid).get());
   // Now read any extra paths, this requires accessing user preferences
   // so we can only do it now. Our constructor is initialized before
   // user preferences are read in.
-  AddDynamicPathList(policy.get(),
-                     "security.sandbox.content.read_path_whitelist",
-                     rdonly);
-  AddDynamicPathList(policy.get(),
-                     "security.sandbox.content.write_path_whitelist",
-                     rdwr);
+  nsAdoptingCString extraReadPathString =
+    Preferences::GetCString("security.sandbox.content.read_path_whitelist");
+  AddDynamicPathList(policy.get(), extraReadPathString, rdonly);
+  nsAdoptingCString extraWritePathString =
+    Preferences::GetCString("security.sandbox.content.write_path_whitelist");
+  AddDynamicPathList(policy.get(), extraWritePathString, rdwr);
 
   // file:// processes get global read permissions
   if (aFileProcess) {
     policy->AddDir(rdonly, "/");
   }
 
   // Return the common policy.
   return policy;
 
 }
 
 void
 SandboxBrokerPolicyFactory::AddDynamicPathList(SandboxBroker::Policy *policy,
-                                               const char* aPathListPref,
-                                               int perms)
-{
-  nsAutoCString pathList;
-  nsresult rv = Preferences::GetCString(aPathListPref, pathList);
-  if (NS_SUCCEEDED(rv)) {
+                                               nsAdoptingCString& pathList,
+                                               int perms) {
+ if (pathList) {
     for (const nsACString& path : pathList.Split(',')) {
       nsCString trimPath(path);
       trimPath.Trim(" ", true, true);
       policy->AddDynamic(perms, trimPath.get());
     }
   }
 }
 
--- a/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.h
+++ b/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.h
@@ -17,15 +17,15 @@ public:
 
 #ifdef MOZ_CONTENT_SANDBOX
   UniquePtr<SandboxBroker::Policy> GetContentPolicy(int aPid, bool aFileProcess);
 #endif
 
 private:
   UniquePtr<const SandboxBroker::Policy> mCommonContentPolicy;
   static void AddDynamicPathList(SandboxBroker::Policy *policy,
-                                 const char* aPathListPref,
+                                 nsAdoptingCString& paths,
                                  int perms);
 };
 
 } // namespace mozilla
 
 #endif // mozilla_SandboxBrokerPolicyFactory_h
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -2504,18 +2504,17 @@ void nsExternalAppHandler::ProcessAnyRef
      }
      mOriginalChannel = nullptr;
    }
 }
 
 bool nsExternalAppHandler::GetNeverAskFlagFromPref(const char * prefName, const char * aContentType)
 {
   // Search the obsolete pref strings.
-  nsAutoCString prefCString;
-  Preferences::GetCString(prefName, prefCString);
+  nsAdoptingCString prefCString = Preferences::GetCString(prefName);
   if (prefCString.IsEmpty()) {
     // Default is true, if not found in the pref string.
     return true;
   }
 
   NS_UnescapeURL(prefCString);
   nsACString::const_iterator start, end;
   prefCString.BeginReading(start);
--- a/widget/GfxInfoBase.cpp
+++ b/widget/GfxInfoBase.cpp
@@ -201,19 +201,18 @@ GetPrefValueForFeature(int32_t aFeature,
 
   aValue = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
   if (!NS_SUCCEEDED(Preferences::GetInt(prefname, &aValue))) {
     return false;
   }
 
   nsCString failureprefname(prefname);
   failureprefname += ".failureid";
-  nsAutoCString failureValue;
-  nsresult rv = Preferences::GetCString(failureprefname.get(), failureValue);
-  if (NS_SUCCEEDED(rv)) {
+  nsAdoptingCString failureValue = Preferences::GetCString(failureprefname.get());
+  if (failureValue) {
     aFailureId = failureValue.get();
   } else {
     aFailureId = "FEATURE_FAILURE_BLACKLIST_PREF";
   }
 
   return true;
 }
 
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1253,39 +1253,39 @@ nsWindow::GeckoViewSupport::Open(const j
 {
     MOZ_ASSERT(NS_IsMainThread());
 
     AUTO_PROFILER_LABEL("nsWindow::GeckoViewSupport::Open", OTHER);
 
     nsCOMPtr<nsIWindowWatcher> ww = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
     MOZ_RELEASE_ASSERT(ww);
 
-    nsAutoCString url;
+    nsAdoptingCString url;
     if (aChromeURI) {
         url = aChromeURI->ToCString();
     } else {
-        nsresult rv = Preferences::GetCString("toolkit.defaultChromeURI", url);
-        if (NS_FAILED(rv)) {
+        url = Preferences::GetCString("toolkit.defaultChromeURI");
+        if (!url) {
             url = NS_LITERAL_CSTRING("chrome://geckoview/content/geckoview.xul");
         }
     }
 
     RefPtr<AndroidView> androidView = new AndroidView();
     androidView->mEventDispatcher->Attach(
             java::EventDispatcher::Ref::From(aDispatcher), nullptr);
     if (aSettings) {
         androidView->mSettings = java::GeckoBundle::Ref::From(aSettings);
     }
 
     nsAutoCString chromeFlags("chrome,dialog=0,resizable,scrollbars");
     if (aPrivateMode) {
         chromeFlags += ",private";
     }
     nsCOMPtr<mozIDOMWindowProxy> domWindow;
-    ww->OpenWindow(nullptr, url.get(), nullptr, chromeFlags.get(),
+    ww->OpenWindow(nullptr, url, nullptr, chromeFlags.get(),
                    androidView, getter_AddRefs(domWindow));
     MOZ_RELEASE_ASSERT(domWindow);
 
     nsCOMPtr<nsPIDOMWindowOuter> pdomWindow =
             nsPIDOMWindowOuter::From(domWindow);
     nsCOMPtr<nsIWidget> widget = WidgetUtils::DOMWindowToWidget(pdomWindow);
     MOZ_ASSERT(widget);
 
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -1169,19 +1169,18 @@ nsLookAndFeel::EnsureInit()
         if (!allowDarkTheme) {
             g_object_set(settings, dark_setting, FALSE, nullptr);
         }
     }
 
     // Allow content Gtk theme override by pref, it's useful when styled Gtk+
     // widgets break web content.
     if (XRE_IsContentProcess()) {
-        nsAutoCString contentThemeName;
-        mozilla::Preferences::GetCString("widget.content.gtk-theme-override",
-                                         contentThemeName);
+        auto contentThemeName =
+            mozilla::Preferences::GetCString("widget.content.gtk-theme-override");
         if (!contentThemeName.IsEmpty()) {
             g_object_set(settings, "gtk-theme-name", contentThemeName.get(), nullptr);
         }
     }
 
     // Scrollbar colors
     style = ClaimStyleContext(MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL);
     gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
--- a/widget/gtk/nsPSPrinters.cpp
+++ b/widget/gtk/nsPSPrinters.cpp
@@ -84,17 +84,17 @@ nsPSPrinterList::GetPrinterList(nsTArray
     // MOZILLA_POSTSCRIPT_PRINTER_LIST or a preference setting
     // print.printer_list, which contains a space-separated list of printer
     // names.
     aList.AppendElement(
             NS_LITERAL_CSTRING(NS_POSTSCRIPT_DRIVER_NAME "default"));
 
     nsAutoCString list(PR_GetEnv("MOZILLA_POSTSCRIPT_PRINTER_LIST"));
     if (list.IsEmpty()) {
-        Preferences::GetCString("print.printer_list", list);
+        list = Preferences::GetCString("print.printer_list");
     }
     if (!list.IsEmpty()) {
         // For each printer (except "default" which was already added),
         // construct a string "PostScript/<name>" and append it to the list.
         char *state;
 
         for (char *name = PL_strtok_r(list.BeginWriting(), " ", &state);
                 nullptr != name;
--- a/xpcom/threads/BackgroundHangMonitor.cpp
+++ b/xpcom/threads/BackgroundHangMonitor.cpp
@@ -740,23 +740,20 @@ BackgroundHangMonitor::IsDisabled() {
   return BackgroundHangManager::sDisabled;
 #else
   return true;
 #endif
 }
 
 bool
 BackgroundHangMonitor::DisableOnBeta() {
-  nsAutoCString clientID;
-  nsresult rv =
-    Preferences::GetCString("toolkit.telemetry.cachedClientID", clientID);
+  nsAdoptingCString clientID = Preferences::GetCString("toolkit.telemetry.cachedClientID");
   bool telemetryEnabled = Preferences::GetBool("toolkit.telemetry.enabled");
 
-  if (!telemetryEnabled || NS_FAILED(rv) ||
-      BackgroundHangMonitor::ShouldDisableOnBeta(clientID)) {
+  if (!telemetryEnabled || !clientID || BackgroundHangMonitor::ShouldDisableOnBeta(clientID)) {
     if (XRE_IsParentProcess()) {
       BackgroundHangMonitor::Shutdown();
     } else {
       BackgroundHangManager::sDisabled = true;
     }
     return true;
   }
 
--- a/xpfe/appshell/nsAppShellService.cpp
+++ b/xpfe/appshell/nsAppShellService.cpp
@@ -109,20 +109,19 @@ nsAppShellService::EnsurePrivateHiddenWi
 nsresult
 nsAppShellService::CreateHiddenWindowHelper(bool aIsPrivate)
 {
   nsresult rv;
   int32_t initialHeight = 100, initialWidth = 100;
 
 #ifdef XP_MACOSX
   uint32_t    chromeMask = 0;
-  nsAutoCString prefVal;
-  rv = Preferences::GetCString("browser.hiddenWindowChromeURL", prefVal);
-  const char* hiddenWindowURL =
-    NS_SUCCEEDED(rv) ? prefVal.get() : DEFAULT_HIDDENWINDOW_URL;
+  nsAdoptingCString prefVal =
+      Preferences::GetCString("browser.hiddenWindowChromeURL");
+  const char* hiddenWindowURL = prefVal.get() ? prefVal.get() : DEFAULT_HIDDENWINDOW_URL;
   if (aIsPrivate) {
     hiddenWindowURL = DEFAULT_HIDDENWINDOW_URL;
   } else {
     mApplicationProvidedHiddenWindow = prefVal.get() ? true : false;
   }
 #else
   static const char hiddenWindowURL[] = DEFAULT_HIDDENWINDOW_URL;
   uint32_t    chromeMask =  nsIWebBrowserChrome::CHROME_ALL;
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -1953,18 +1953,17 @@ NS_IMETHODIMP nsXULWindow::CreateNewCont
 
   // We need to create a new top level window and then enter a nested
   // loop. Eventually the new window will be told that it has loaded,
   // at which time we know it is safe to spin out of the nested loop
   // and allow the opening code to proceed.
 
   nsCOMPtr<nsIURI> uri;
 
-  nsAutoCString urlStr;
-  Preferences::GetCString("browser.chromeURL", urlStr);
+  nsAdoptingCString urlStr = Preferences::GetCString("browser.chromeURL");
   if (urlStr.IsEmpty()) {
     urlStr.AssignLiteral("chrome://navigator/content/navigator.xul");
   }
 
   nsCOMPtr<nsIIOService> service(do_GetService(NS_IOSERVICE_CONTRACTID));
   if (service) {
     service->NewURI(urlStr, nullptr, nullptr, getter_AddRefs(uri));
   }