Skip to content

Commit 4f2f93d

Browse files
Jake ChampionJakeChampion
authored andcommitted
report error if the name property can not be cast to a string
1 parent 6455bf9 commit 4f2f93d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ const EVP_MD *createDigestAlgorithm(JSContext *cx, JS::HandleObject key) {
2121
JS::RootedValue name_val(cx);
2222
JS_GetProperty(cx, hash, "name", &name_val);
2323
size_t name_length;
24-
auto cc = encode(cx, name_val, &name_length);
24+
auto name_chars = encode(cx, name_val, &name_length);
25+
if (!name_chars) {
26+
JS_ReportErrorLatin1(cx, "NotSupportedError");
27+
return nullptr;
28+
}
2529

26-
std::string_view name(cc.get(), name_length);
30+
std::string_view name(name_chars.get(), name_length);
2731
if (name == "SHA-1") {
2832
return EVP_sha1();
2933
} else if (name == "SHA-224") {

0 commit comments

Comments
 (0)