Bug 1026656 - Fix resolve accessing temporary variable. r=valentin.gosu, r=mcmanus
authorNicu Badescu <badescunicu@yahoo.com>
Sun, 22 Jun 2014 15:55:00 -0400
changeset 191031 9f8a077acb66b8cd9249a71277c7b8b49df1c556
parent 191030 7f10a0e42e895d8a66920ac8b076d81b61a5a562
child 191032 72f554d3e1c89ce66d0f7b8025bb93030f306f57
push id8417
push userryanvm@gmail.com
push dateThu, 26 Jun 2014 21:15:47 +0000
treeherderb2g-inbound@3bef42144aab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin.gosu, mcmanus
bugs1026656
milestone33.0a1
Bug 1026656 - Fix resolve accessing temporary variable. r=valentin.gosu, r=mcmanus
netwerk/dns/nsDNSService2.cpp
--- a/netwerk/dns/nsDNSService2.cpp
+++ b/netwerk/dns/nsDNSService2.cpp
@@ -671,18 +671,19 @@ nsDNSService::AsyncResolve(const nsACStr
     if (!res)
         return NS_ERROR_OFFLINE;
 
     if (mOffline)
         flags |= RESOLVE_OFFLINE;
 
     const nsACString *hostPtr = &hostname;
 
+    nsAutoCString strLocalhost(NS_LITERAL_CSTRING("localhost"));
     if (localDomain) {
-        hostPtr = &(NS_LITERAL_CSTRING("localhost"));
+        hostPtr = &strLocalhost;
     }
 
     nsresult rv;
     nsAutoCString hostACE;
     if (idn && !IsASCII(*hostPtr)) {
         if (NS_SUCCEEDED(idn->ConvertUTF8toACE(*hostPtr, hostACE)))
             hostPtr = &hostACE;
     }
@@ -780,18 +781,19 @@ nsDNSService::Resolve(const nsACString &
 
     NS_ENSURE_TRUE(res, NS_ERROR_OFFLINE);
 
     if (mOffline)
         flags |= RESOLVE_OFFLINE;
 
     const nsACString *hostPtr = &hostname;
 
+    nsAutoCString strLocalhost(NS_LITERAL_CSTRING("localhost"));
     if (localDomain) {
-        hostPtr = &(NS_LITERAL_CSTRING("localhost"));
+        hostPtr = &strLocalhost;
     }
 
     nsresult rv;
     nsAutoCString hostACE;
     if (idn && !IsASCII(*hostPtr)) {
         if (NS_SUCCEEDED(idn->ConvertUTF8toACE(*hostPtr, hostACE)))
             hostPtr = &hostACE;
     }