Skip to content

Commit f0ff7cd

Browse files
Jake ChampionJakeChampion
authored andcommitted
ensure usages can fit in a uint8_t
1 parent 077adfd commit f0ff7cd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

c-dependencies/js-compute-runtime/builtins/crypto-key.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <utility>
12
#include "crypto-key.h"
23
#include "crypto-algorithm.h"
34
#include "js-compute-builtins.h"
@@ -651,7 +652,9 @@ bool CryptoKey::canSign(JS::HandleObject self) {
651652

652653
bool CryptoKey::canVerify(JS::HandleObject self) {
653654
MOZ_ASSERT(is_instance(self));
654-
auto usage = CryptoKeyUsages(JS::GetReservedSlot(self, Slots::Usages).toInt32());
655+
auto usages = JS::GetReservedSlot(self, Slots::Usages).toInt32();
656+
MOZ_ASSERT(std::in_range<std::uint8_t>(usages));
657+
auto usage = CryptoKeyUsages(static_cast<uint8_t>(usages));
655658
return usage.canVerify();
656659
}
657660

0 commit comments

Comments
 (0)