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
(cherry picked from commit 1fcf9b87c8)
This commit is contained in:
Gang Zhao authored and Riccardo Cipolleschi committed 2026-10-26 13:36:39 +00:00
1 parent 4292cc3bc4
commit 39276e6d70
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 {