mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04: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
931551c3eb
commit
a01932fc4c
@ -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]];
|
||||
// Cast idx to size_t before using it as an array-index,
|
||||
// to pacify clang 'Wchar-subscripts' warning:
|
||||
size_t idx = static_cast<size_t>(out[i]);
|
||||
MOZ_ASSERT(idx < MOZ_ARRAY_LENGTH(sAlphabet),
|
||||
"out of bounds index for 'sAlphabet'");
|
||||
out[i] = sAlphabet[idx];
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user