Fix: JSI Value::toString() should check the result type (#59146)

Summary:
Pull Request resolved: https://github.com/react/react-native/pull/59146

`global.String` could be overridden. We always need to check the return type before casting to `jsi::String`.

Changelog: [Internal]

Reviewed By: avp

Differential Revision: D125707029

fbshipit-source-id: 15d3f83ac23d8bceb24e9e13a1f67dc4b61bb3b8
This commit is contained in:
Gang Zhao authored and meta-codesync[bot] committed 2026-10-19 14:18:50 -07:00
1 parent ccca5d7a29
commit 1fcf9b87c8
1 file changed
+1 -1
@@ -923,7 +923,7 @@ String Value::asString(IRuntime& rt) && {
String Value::toString(IRuntime& runtime) const {
Function toString = runtime.global().getPropertyAsFunction(runtime, "String");
return toString.call(runtime, *this).getString(runtime);
return toString.call(runtime, *this).asString(runtime);
}
uint64_t BigInt::asUint64(IRuntime& runtime) const {