Bug 1485325 - Avoid nsTSubstring::GetMutableData() in URL classifier. r=francois
authorHenri Sivonen <hsivonen@hsivonen.fi>
Wed, 22 Aug 2018 23:07:59 +0000
changeset 488077 fa1966cf5f5c2efe0475c5d684f619ccde2e3779
parent 488076 ea96184d8874fc4763c08e4590ab007bf939bc97
child 488078 bca1895bb276e2f50401f2838ecb42d38b3d9c20
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrancois
bugs1485325
milestone63.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 1485325 - Avoid nsTSubstring::GetMutableData() in URL classifier. r=francois MozReview-Commit-ID: EzyOTuEZ9Ot Differential Revision: https://phabricator.services.mozilla.com/D3966
toolkit/components/url-classifier/HashStore.cpp
--- a/toolkit/components/url-classifier/HashStore.cpp
+++ b/toolkit/components/url-classifier/HashStore.cpp
@@ -277,33 +277,32 @@ HashStore::CheckChecksum(uint32_t aFileS
   if (!mInputStream) {
     return NS_OK;
   }
 
   // Check for file corruption by
   // comparing the stored checksum to actual checksum of data
   nsAutoCString hash;
   nsAutoCString compareHash;
-  char *data;
   uint32_t read;
 
   nsresult rv = CalculateChecksum(hash, aFileSize, true);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  compareHash.GetMutableData(&data, hash.Length());
+  compareHash.SetLength(hash.Length());
 
   if (hash.Length() > aFileSize) {
     NS_WARNING("SafeBrowing file not long enough to store its hash");
     return NS_ERROR_FAILURE;
   }
   nsCOMPtr<nsISeekableStream> seekIn = do_QueryInterface(mInputStream);
   rv = seekIn->Seek(nsISeekableStream::NS_SEEK_SET, aFileSize - hash.Length());
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = mInputStream->Read(data, hash.Length(), &read);
+  rv = mInputStream->Read(compareHash.BeginWriting(), hash.Length(), &read);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ASSERTION(read == hash.Length(), "Could not read hash bytes");
 
   if (!hash.Equals(compareHash)) {
     NS_WARNING("Safebrowing file failed checksum.");
     return NS_ERROR_FAILURE;
   }