fix crash when converting symbol or BigInt to dynamic
Summary: Throws a JS error instead of crashing Hermes with an invariant when trying to convert a JS symbol or BigInt to a folly::dynamic value. Changelog: [General][Fixed] - Fixed crash when converting JS symbol to folly::dynamic Reviewed By: javache Differential Revision: D40444164 fbshipit-source-id: 37df8059b2eb425563f30cf1e9c0436e8d665b34
This commit is contained in:
Родитель
1bb5cca72d
Коммит
428feb2f76
|
@ -129,8 +129,7 @@ void dynamicFromValueShallow(
|
|||
output = value.getNumber();
|
||||
} else if (value.isString()) {
|
||||
output = value.getString(runtime).utf8(runtime);
|
||||
} else {
|
||||
CHECK(value.isObject());
|
||||
} else if (value.isObject()) {
|
||||
Object obj = value.getObject(runtime);
|
||||
if (obj.isArray(runtime)) {
|
||||
output = folly::dynamic::array();
|
||||
|
@ -140,6 +139,12 @@ void dynamicFromValueShallow(
|
|||
output = folly::dynamic::object();
|
||||
}
|
||||
stack.emplace_back(&output, std::move(obj));
|
||||
} else if (value.isBigInt()) {
|
||||
throw JSError(runtime, "JS BigInts are not convertible to dynamic");
|
||||
} else if (value.isSymbol()) {
|
||||
throw JSError(runtime, "JS Symbols are not convertible to dynamic");
|
||||
} else {
|
||||
throw JSError(runtime, "Value is not convertible to dynamic");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче