Bug 1448755 - Use AssignLiteral and AssignASCII for short zero-terminated strings in networking. r?jduell. draft
authorHenri Sivonen <hsivonen@hsivonen.fi>
Mon, 26 Mar 2018 09:02:32 +0300
changeset 773651 f227c286cf735e1c6b4ba6523f62e19798517a54
parent 773650 07c6cf53b38f22da90d09145d400266c3296d7e1
child 773652 a4da4d10be08a745347d7a08ddf43d469883a122
push id104266
push userbmo:hsivonen@hsivonen.fi
push dateWed, 28 Mar 2018 07:33:03 +0000
reviewersjduell
bugs1448755
milestone61.0a1
Bug 1448755 - Use AssignLiteral and AssignASCII for short zero-terminated strings in networking. r?jduell. MozReview-Commit-ID: HPzng5p6qkb
netwerk/base/Dashboard.cpp
netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
netwerk/wifi/nsWifiAccessPoint.cpp
--- a/netwerk/base/Dashboard.cpp
+++ b/netwerk/base/Dashboard.cpp
@@ -763,19 +763,19 @@ Dashboard::GetDNSCacheEntries(DnsData *d
             if (!addr) {
                 JS_ReportOutOfMemory(cx);
                 return NS_ERROR_OUT_OF_MEMORY;
             }
             CopyASCIItoUTF16(dnsData->mData[i].hostaddr[j], *addr);
         }
 
         if (dnsData->mData[i].family == PR_AF_INET6) {
-            CopyASCIItoUTF16("ipv6", entry.mFamily);
+            entry.mFamily.AssignLiteral("ipv6");
         } else {
-            CopyASCIItoUTF16("ipv4", entry.mFamily);
+            entry.mFamily.AssignLiteral("ipv4");
         }
     }
 
     JS::RootedValue val(cx);
     if (!ToJSValue(cx, dict, &val)) {
         return NS_ERROR_FAILURE;
     }
     dnsData->mCallback->OnDashboardDataAvailable(val);
--- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
+++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
@@ -743,21 +743,21 @@ mozTXTToHTMLConv::SmilyHit(const char16_
   {
     if (!col0)
     {
       outputHTML.Truncate();
       outputHTML.Append(char16_t(' '));
     }
 
     outputHTML.AppendLiteral("<span class=\""); // <span class="
-    AppendASCIItoUTF16(imageName, outputHTML);  // e.g. smiley-frown
+    outputHTML.AppendASCII(imageName);          // e.g. smiley-frown
     outputHTML.AppendLiteral("\" title=\"");    // " title="
-    AppendASCIItoUTF16(tagTXT, outputHTML);     // smiley tooltip
+    outputHTML.AppendASCII(tagTXT);             // smiley tooltip
     outputHTML.AppendLiteral("\"><span>");      // "><span>
-    AppendASCIItoUTF16(tagTXT, outputHTML);     // original text
+    outputHTML.AppendASCII(tagTXT);             // original text
     outputHTML.AppendLiteral("</span></span>"); // </span></span>
     glyphTextLen = (col0 ? 0 : 1) + tagLen;
     return true;
   }
 
   return false;
 }
 
--- a/netwerk/wifi/nsWifiAccessPoint.cpp
+++ b/netwerk/wifi/nsWifiAccessPoint.cpp
@@ -30,17 +30,17 @@ NS_IMETHODIMP nsWifiAccessPoint::GetMac(
   aMac.Assign(mMac);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsWifiAccessPoint::GetSsid(nsAString& aSsid)
 {
   // just assign and embedded nulls will truncate resulting
   // in a displayable string.
-  CopyASCIItoUTF16(mSsid, aSsid);
+  aSsid.AssignASCII(mSsid);
   return NS_OK;
 }
 
 
 NS_IMETHODIMP nsWifiAccessPoint::GetRawSSID(nsACString& aRawSsid)
 {
   aRawSsid.Assign(mSsid, mSsidLen); // SSIDs are 32 chars long
   return NS_OK;