From f7d4cef5738c145a936e999b60c97dd85a4d0123 Mon Sep 17 00:00:00 2001 From: Henri Sivonen Date: Wed, 22 Aug 2018 23:07:59 +0000 Subject: [PATCH] Bug 1485325 - Avoid nsTSubstring::GetMutableData() in URL classifier. r=francois MozReview-Commit-ID: EzyOTuEZ9Ot Differential Revision: https://phabricator.services.mozilla.com/D3966 --HG-- extra : moz-landing-system : lando --- toolkit/components/url-classifier/HashStore.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/toolkit/components/url-classifier/HashStore.cpp b/toolkit/components/url-classifier/HashStore.cpp index 60cdaa0fdc96..a0999851553a 100644 --- a/toolkit/components/url-classifier/HashStore.cpp +++ b/toolkit/components/url-classifier/HashStore.cpp @@ -282,13 +282,12 @@ HashStore::CheckChecksum(uint32_t aFileSize) // 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"); @@ -298,7 +297,7 @@ HashStore::CheckChecksum(uint32_t aFileSize) 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");