Bug 1656515 - Decompress multilocale.txt if necessary r=dthayer
authorJames Willcox <snorp@snorp.net>
Fri, 14 Aug 2020 18:51:13 +0000
changeset 544730 9a94d0040d2f9b0bf93fa02a624d5805e563e920
parent 544729 71a6d628bf09d8b3da26510d75b16b07ca7cdee2
child 544731 565097a8dd7db08d82151d40b7c3fcfdb6288c48
push id124228
push userjwillcox@mozilla.com
push dateFri, 14 Aug 2020 20:42:30 +0000
treeherderautoland@9a94d0040d2f [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 buf = MakeUnique<uint8_t[]>(item->RealSize());
+    CacheAwareZipCursor cursor(item, zip, buf.get(), item->RealSize());
+
+    uint32_t count;
+    uint8_t* data = cursor.Read(&count);
+
+    if (count != item->RealSize()) {
+      return false;
+    }
+
+    aOutString->Assign(reinterpret_cast<const char*>(data), 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)))) {