mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 1083373 part 2: Assert that array index is in-bounds, and cast it from char to size_t to fix clang warning. r=edwin
This commit is contained in:
parent
c1bc87650e
commit
1b6621fefd
@ -10,6 +10,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "ClearKeyUtils.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Endian.h"
|
||||
#include "mozilla/NullPtr.h"
|
||||
#include "openaes/oaes_lib.h"
|
||||
@ -106,7 +108,12 @@ EncodeBase64Web(vector<uint8_t> aBinary, string& aEncoded)
|
||||
out[i] += (*data >> (shift + 2)) & sMask;
|
||||
shift = (shift + 2) % 8;
|
||||
|
||||
out[i] = sAlphabet[out[i]];
|
||||
auto idx = out[i];
|
||||
MOZ_ASSERT(idx >= 0 &&
|
||||
static_cast<size_t>(idx) < MOZ_ARRAY_LENGTH(sAlphabet),
|
||||
"out of bounds index for 'sAlphabet'");
|
||||
// Cast idx to size_t to pacify clang 'Wchar-subscripts' warning:
|
||||
out[i] = sAlphabet[static_cast<size_t>(idx)];
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user