Bug 1656515 - Decompress multilocale.txt if necessary r=dthayer
☠☠ backed out by 3bfe3b28bf50 ☠ ☠
authorJames Willcox <snorp@snorp.net>
Mon, 10 Aug 2020 20:44:56 +0000
changeset 544180 1835ac58c6174ae3a12fcb539a6b6de37667ad03
parent 544179 6298f483be0e6019dbe39d28339cb1b7c92345fc
child 544181 c02934a6103229b5b6e4b265cbb610b1f7c510aa
push id123870
push userjwillcox@mozilla.com
push dateMon, 10 Aug 2020 21:06:36 +0000
treeherderautoland@1835ac58c617 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdthayer
bugs1656515
milestone81.0a1
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
Bug 1656515 - Decompress multilocale.txt if necessary r=dthayer Differential Revision: https://phabricator.services.mozilla.com/D86604
intl/locale/LocaleService.cpp
--- a/intl/locale/LocaleService.cpp
+++ b/intl/locale/LocaleService.cpp
@@ -292,22 +292,34 @@ bool LocaleService::LanguagesMatch(const
 }
 
 bool LocaleService::IsServer() { return mIsServer; }
 
 static bool GetGREFileContents(const char* aFilePath, nsCString* aOutString) {
   // Look for the requested file in omnijar.
   RefPtr<CacheAwareZipReader> zip = Omnijar::GetReader(Omnijar::GRE);
   if (zip) {
-    uint32_t length;
-    const uint8_t* data = zip->GetData(aFilePath, &length);
-    if (!data) {
+    const auto item = zip->GetItem(aFilePath);
+    if (!item) {
       return false;
     }
-    aOutString->Assign(reinterpret_cast<const char*>(data), length);
+
+    MOZ_ASSERT(item->RealSize());
+
+    auto data = MakeUnique<uint8_t>(item->RealSize());
+    CacheAwareZipCursor cursor(item, zip, data.get(), item->RealSize());
+
+    uint32_t count;
+    cursor.Read(&count);
+
+    if (count != item->RealSize()) {
+      return false;
+    }
+
+    aOutString->Assign(reinterpret_cast<const char*>(data.get()), count);
     return true;
   }
 
   // If we didn't have an omnijar (i.e. we're running a non-packaged
   // build), then look in the GRE directory.
   nsCOMPtr<nsIFile> path;
   if (NS_FAILED(nsDirectoryService::gService->Get(
           NS_GRE_DIR, NS_GET_IID(nsIFile), getter_AddRefs(path)))) {