Bug 1741210 - Make type conversions more explicit. r=dom-storage-reviewers,janv

Differential Revision: https://phabricator.services.mozilla.com/D131248
This commit is contained in:
Jari Jalkanen 2021-11-22 15:53:45 +00:00
Родитель 1e2ca5720b
Коммит 762afb8a19
1 изменённых файлов: 9 добавлений и 3 удалений

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

@ -8,6 +8,7 @@
#include <stddef.h>
#include "mozilla/Assertions.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/fallible.h"
#include "nsDebug.h"
#include "nsString.h"
@ -51,15 +52,20 @@ bool SnappyUncompress(const nsACString& aSource, nsACString& aDest) {
const char* compressed = aSource.BeginReading();
size_t compressedLength = aSource.Length();
auto compressedLength = static_cast<size_t>(aSource.Length());
size_t uncompressedLength;
size_t uncompressedLength = 0u;
if (!snappy::GetUncompressedLength(compressed, compressedLength,
&uncompressedLength)) {
return false;
}
aDest.SetLength(uncompressedLength);
CheckedUint32 checkedLength(uncompressedLength);
if (!checkedLength.isValid()) {
return false;
}
aDest.SetLength(checkedLength.value());
if (!snappy::RawUncompress(compressed, compressedLength,
aDest.BeginWriting())) {