Bug 1545521: Use lz4_decompress_safe to decode add-on manager startup cache blobs. r=aswan

In previous versions of the LZ4 library, lz4_decompress_fast, which does not
take an input buffer size, was supposed to be faster than lz4_decompress_safe,
which does. In newer versions, however, the reverse is supposed to be true,
and lz4_decompress_fast is therefore deprecated.

This patch updates our code to use the now-preferred "safe" version of the
API.

Differential Revision: https://phabricator.services.mozilla.com/D28128

--HG--
extra : rebase_source : 572e7355ed6b31936632e977ee1584834e441fec
This commit is contained in:
Kris Maglione 2019-04-18 13:17:37 -07:00
Родитель 0042440c14
Коммит 951c77f570
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -116,12 +116,18 @@ static Result<nsCString, nsresult> DecodeLZ4(const nsACString& lz4,
auto size = LittleEndian::readUint32(data);
data += 4;
size_t dataLen = lz4.EndReading() - data;
size_t outputSize;
nsCString result;
if (!result.SetLength(size, fallible) ||
!LZ4::decompress(data, result.BeginWriting(), size)) {
!LZ4::decompress(data, dataLen, result.BeginWriting(), size,
&outputSize)) {
return Err(NS_ERROR_UNEXPECTED);
}
MOZ_DIAGNOSTIC_ASSERT(size == outputSize);
return result;
}