Add big scary term "Reentrant" to fxjs methods that enter JS. Allows easier visualization of places where the JS side may change legitimacy of previously extracted values. -- Gemini-generated rename, no funny business (hopefully). Change-Id: I2aeab6e4b8092a16258b3c3586cebaa34ebaf21a Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/147770 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/cfx_v8.cpp b/fxjs/cfx_v8.cpp index 9eb5b1f..49f9c96 100644 --- a/fxjs/cfx_v8.cpp +++ b/fxjs/cfx_v8.cpp
@@ -13,21 +13,21 @@ CFX_V8::~CFX_V8() = default; -v8::Local<v8::Value> CFX_V8::GetObjectProperty( +v8::Local<v8::Value> CFX_V8::GetObjectPropertyReentrant( v8::Local<v8::Object> pObj, ByteStringView bsUTF8PropertyName) { return fxv8::ReentrantGetObjectPropertyHelper(GetIsolate(), pObj, bsUTF8PropertyName); } -std::vector<WideString> CFX_V8::GetObjectPropertyNames( +std::vector<WideString> CFX_V8::GetObjectPropertyNamesReentrant( v8::Local<v8::Object> pObj) { return fxv8::ReentrantGetObjectPropertyNamesHelper(GetIsolate(), pObj); } -void CFX_V8::PutObjectProperty(v8::Local<v8::Object> pObj, - ByteStringView bsUTF8PropertyName, - v8::Local<v8::Value> pPut) { +void CFX_V8::PutObjectPropertyReentrant(v8::Local<v8::Object> pObj, + ByteStringView bsUTF8PropertyName, + v8::Local<v8::Value> pPut) { fxv8::ReentrantPutObjectPropertyHelper(GetIsolate(), pObj, bsUTF8PropertyName, pPut); } @@ -46,14 +46,15 @@ return fxv8::NewObjectHelper(GetIsolate()); } -void CFX_V8::PutArrayElement(v8::Local<v8::Array> pArray, - size_t index, - v8::Local<v8::Value> pValue) { +void CFX_V8::PutArrayElementReentrant(v8::Local<v8::Array> pArray, + size_t index, + v8::Local<v8::Value> pValue) { fxv8::ReentrantPutArrayElementHelper(GetIsolate(), pArray, index, pValue); } -v8::Local<v8::Value> CFX_V8::GetArrayElement(v8::Local<v8::Array> pArray, - size_t index) { +v8::Local<v8::Value> CFX_V8::GetArrayElementReentrant( + v8::Local<v8::Array> pArray, + size_t index) { return fxv8::ReentrantGetArrayElementHelper(GetIsolate(), pArray, index); } @@ -100,31 +101,31 @@ return fxv8::NewDateHelper(GetIsolate(), d); } -int CFX_V8::ToInt32(v8::Local<v8::Value> pValue) { +int CFX_V8::ToInt32Reentrant(v8::Local<v8::Value> pValue) { return fxv8::ReentrantToInt32Helper(GetIsolate(), pValue); } -bool CFX_V8::ToBoolean(v8::Local<v8::Value> pValue) { +bool CFX_V8::ToBooleanReentrant(v8::Local<v8::Value> pValue) { return fxv8::ReentrantToBooleanHelper(GetIsolate(), pValue); } -double CFX_V8::ToDouble(v8::Local<v8::Value> pValue) { +double CFX_V8::ToDoubleReentrant(v8::Local<v8::Value> pValue) { return fxv8::ReentrantToDoubleHelper(GetIsolate(), pValue); } -WideString CFX_V8::ToWideString(v8::Local<v8::Value> pValue) { +WideString CFX_V8::ToWideStringReentrant(v8::Local<v8::Value> pValue) { return fxv8::ReentrantToWideStringHelper(GetIsolate(), pValue); } -ByteString CFX_V8::ToByteString(v8::Local<v8::Value> pValue) { +ByteString CFX_V8::ToByteStringReentrant(v8::Local<v8::Value> pValue) { return fxv8::ReentrantToByteStringHelper(GetIsolate(), pValue); } -v8::Local<v8::Object> CFX_V8::ToObject(v8::Local<v8::Value> pValue) { +v8::Local<v8::Object> CFX_V8::ToObjectReentrant(v8::Local<v8::Value> pValue) { return fxv8::ReentrantToObjectHelper(GetIsolate(), pValue); } -v8::Local<v8::Array> CFX_V8::ToArray(v8::Local<v8::Value> pValue) { +v8::Local<v8::Array> CFX_V8::ToArrayReentrant(v8::Local<v8::Value> pValue) { return fxv8::ReentrantToArrayHelper(GetIsolate(), pValue); }
diff --git a/fxjs/cfx_v8.h b/fxjs/cfx_v8.h index 2695172..1f50359 100644 --- a/fxjs/cfx_v8.h +++ b/fxjs/cfx_v8.h
@@ -34,29 +34,31 @@ v8::Local<v8::String> NewString(WideStringView str); v8::Local<v8::Date> NewDate(double d); - int ToInt32(v8::Local<v8::Value> pValue); - bool ToBoolean(v8::Local<v8::Value> pValue); - double ToDouble(v8::Local<v8::Value> pValue); - WideString ToWideString(v8::Local<v8::Value> pValue); - ByteString ToByteString(v8::Local<v8::Value> pValue); - v8::Local<v8::Object> ToObject(v8::Local<v8::Value> pValue); - v8::Local<v8::Array> ToArray(v8::Local<v8::Value> pValue); + int ToInt32Reentrant(v8::Local<v8::Value> pValue); + bool ToBooleanReentrant(v8::Local<v8::Value> pValue); + double ToDoubleReentrant(v8::Local<v8::Value> pValue); + WideString ToWideStringReentrant(v8::Local<v8::Value> pValue); + ByteString ToByteStringReentrant(v8::Local<v8::Value> pValue); + v8::Local<v8::Object> ToObjectReentrant(v8::Local<v8::Value> pValue); + v8::Local<v8::Array> ToArrayReentrant(v8::Local<v8::Value> pValue); // Arrays. size_t GetArrayLength(v8::Local<v8::Array> pArray); - v8::Local<v8::Value> GetArrayElement(v8::Local<v8::Array> pArray, - size_t index); - void PutArrayElement(v8::Local<v8::Array> pArray, - size_t index, - v8::Local<v8::Value> pValue); + v8::Local<v8::Value> GetArrayElementReentrant(v8::Local<v8::Array> pArray, + size_t index); + void PutArrayElementReentrant(v8::Local<v8::Array> pArray, + size_t index, + v8::Local<v8::Value> pValue); // Objects. - std::vector<WideString> GetObjectPropertyNames(v8::Local<v8::Object> pObj); - v8::Local<v8::Value> GetObjectProperty(v8::Local<v8::Object> pObj, - ByteStringView bsUTF8PropertyName); - void PutObjectProperty(v8::Local<v8::Object> pObj, - ByteStringView bsUTF8PropertyName, - v8::Local<v8::Value> pValue); + std::vector<WideString> GetObjectPropertyNamesReentrant( + v8::Local<v8::Object> pObj); + v8::Local<v8::Value> GetObjectPropertyReentrant( + v8::Local<v8::Object> pObj, + ByteStringView bsUTF8PropertyName); + void PutObjectPropertyReentrant(v8::Local<v8::Object> pObj, + ByteStringView bsUTF8PropertyName, + v8::Local<v8::Value> pValue); protected: void SetIsolate(v8::Isolate* isolate) { isolate_ = isolate; }
diff --git a/fxjs/cfx_v8_unittest.cpp b/fxjs/cfx_v8_unittest.cpp index 6b303ef..4e88bc5 100644 --- a/fxjs/cfx_v8_unittest.cpp +++ b/fxjs/cfx_v8_unittest.cpp
@@ -43,25 +43,26 @@ v8::Context::Scope context_scope(v8::Context::New(isolate())); v8::Local<v8::Value> empty; - EXPECT_FALSE(cfx_v8()->ToBoolean(empty)); - EXPECT_EQ(0, cfx_v8()->ToInt32(empty)); - EXPECT_EQ(0.0, cfx_v8()->ToDouble(empty)); - EXPECT_EQ("", cfx_v8()->ToByteString(empty)); - EXPECT_EQ(L"", cfx_v8()->ToWideString(empty)); - EXPECT_TRUE(cfx_v8()->ToObject(empty).IsEmpty()); - EXPECT_TRUE(cfx_v8()->ToArray(empty).IsEmpty()); + EXPECT_FALSE(cfx_v8()->ToBooleanReentrant(empty)); + EXPECT_EQ(0, cfx_v8()->ToInt32Reentrant(empty)); + EXPECT_EQ(0.0, cfx_v8()->ToDoubleReentrant(empty)); + EXPECT_EQ("", cfx_v8()->ToByteStringReentrant(empty)); + EXPECT_EQ(L"", cfx_v8()->ToWideStringReentrant(empty)); + EXPECT_TRUE(cfx_v8()->ToObjectReentrant(empty).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToArrayReentrant(empty).IsEmpty()); // Can't set properties on empty objects, but does not fault. v8::Local<v8::Value> marker = cfx_v8()->NewNumber(2); v8::Local<v8::Object> empty_object; - cfx_v8()->PutObjectProperty(empty_object, "clams", marker); - EXPECT_TRUE(cfx_v8()->GetObjectProperty(empty_object, "clams").IsEmpty()); - EXPECT_EQ(0u, cfx_v8()->GetObjectPropertyNames(empty_object).size()); + cfx_v8()->PutObjectPropertyReentrant(empty_object, "clams", marker); + EXPECT_TRUE( + cfx_v8()->GetObjectPropertyReentrant(empty_object, "clams").IsEmpty()); + EXPECT_EQ(0u, cfx_v8()->GetObjectPropertyNamesReentrant(empty_object).size()); // Can't set elements in empty arrays, but does not fault. v8::Local<v8::Array> empty_array; - cfx_v8()->PutArrayElement(empty_array, 0, marker); - EXPECT_TRUE(cfx_v8()->GetArrayElement(empty_array, 0).IsEmpty()); + cfx_v8()->PutArrayElementReentrant(empty_array, 0, marker); + EXPECT_TRUE(cfx_v8()->GetArrayElementReentrant(empty_array, 0).IsEmpty()); EXPECT_EQ(0u, cfx_v8()->GetArrayLength(empty_array)); } @@ -71,13 +72,13 @@ v8::Context::Scope context_scope(v8::Context::New(isolate())); auto nullz = cfx_v8()->NewNull(); - EXPECT_FALSE(cfx_v8()->ToBoolean(nullz)); - EXPECT_EQ(0, cfx_v8()->ToInt32(nullz)); - EXPECT_EQ(0.0, cfx_v8()->ToDouble(nullz)); - EXPECT_EQ("null", cfx_v8()->ToByteString(nullz)); - EXPECT_EQ(L"null", cfx_v8()->ToWideString(nullz)); - EXPECT_TRUE(cfx_v8()->ToObject(nullz).IsEmpty()); - EXPECT_TRUE(cfx_v8()->ToArray(nullz).IsEmpty()); + EXPECT_FALSE(cfx_v8()->ToBooleanReentrant(nullz)); + EXPECT_EQ(0, cfx_v8()->ToInt32Reentrant(nullz)); + EXPECT_EQ(0.0, cfx_v8()->ToDoubleReentrant(nullz)); + EXPECT_EQ("null", cfx_v8()->ToByteStringReentrant(nullz)); + EXPECT_EQ(L"null", cfx_v8()->ToWideStringReentrant(nullz)); + EXPECT_TRUE(cfx_v8()->ToObjectReentrant(nullz).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToArrayReentrant(nullz).IsEmpty()); } TEST_F(CFXV8UnitTest, NewUndefined) { @@ -86,13 +87,13 @@ v8::Context::Scope context_scope(v8::Context::New(isolate())); auto undef = cfx_v8()->NewUndefined(); - EXPECT_FALSE(cfx_v8()->ToBoolean(undef)); - EXPECT_EQ(0, cfx_v8()->ToInt32(undef)); - EXPECT_TRUE(isnan(cfx_v8()->ToDouble(undef))); - EXPECT_EQ("undefined", cfx_v8()->ToByteString(undef)); - EXPECT_EQ(L"undefined", cfx_v8()->ToWideString(undef)); - EXPECT_TRUE(cfx_v8()->ToObject(undef).IsEmpty()); - EXPECT_TRUE(cfx_v8()->ToArray(undef).IsEmpty()); + EXPECT_FALSE(cfx_v8()->ToBooleanReentrant(undef)); + EXPECT_EQ(0, cfx_v8()->ToInt32Reentrant(undef)); + EXPECT_TRUE(isnan(cfx_v8()->ToDoubleReentrant(undef))); + EXPECT_EQ("undefined", cfx_v8()->ToByteStringReentrant(undef)); + EXPECT_EQ(L"undefined", cfx_v8()->ToWideStringReentrant(undef)); + EXPECT_TRUE(cfx_v8()->ToObjectReentrant(undef).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToArrayReentrant(undef).IsEmpty()); } TEST_F(CFXV8UnitTest, NewBoolean) { @@ -101,22 +102,22 @@ v8::Context::Scope context_scope(v8::Context::New(isolate())); auto boolz = cfx_v8()->NewBoolean(true); - EXPECT_TRUE(cfx_v8()->ToBoolean(boolz)); - EXPECT_EQ(1, cfx_v8()->ToInt32(boolz)); - EXPECT_EQ(1.0, cfx_v8()->ToDouble(boolz)); - EXPECT_EQ("true", cfx_v8()->ToByteString(boolz)); - EXPECT_EQ(L"true", cfx_v8()->ToWideString(boolz)); - EXPECT_TRUE(cfx_v8()->ToObject(boolz).IsEmpty()); - EXPECT_TRUE(cfx_v8()->ToArray(boolz).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToBooleanReentrant(boolz)); + EXPECT_EQ(1, cfx_v8()->ToInt32Reentrant(boolz)); + EXPECT_EQ(1.0, cfx_v8()->ToDoubleReentrant(boolz)); + EXPECT_EQ("true", cfx_v8()->ToByteStringReentrant(boolz)); + EXPECT_EQ(L"true", cfx_v8()->ToWideStringReentrant(boolz)); + EXPECT_TRUE(cfx_v8()->ToObjectReentrant(boolz).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToArrayReentrant(boolz).IsEmpty()); boolz = cfx_v8()->NewBoolean(false); - EXPECT_FALSE(cfx_v8()->ToBoolean(boolz)); - EXPECT_EQ(0, cfx_v8()->ToInt32(boolz)); - EXPECT_EQ(0.0, cfx_v8()->ToDouble(boolz)); - EXPECT_EQ("false", cfx_v8()->ToByteString(boolz)); - EXPECT_EQ(L"false", cfx_v8()->ToWideString(boolz)); - EXPECT_TRUE(cfx_v8()->ToObject(boolz).IsEmpty()); - EXPECT_TRUE(cfx_v8()->ToArray(boolz).IsEmpty()); + EXPECT_FALSE(cfx_v8()->ToBooleanReentrant(boolz)); + EXPECT_EQ(0, cfx_v8()->ToInt32Reentrant(boolz)); + EXPECT_EQ(0.0, cfx_v8()->ToDoubleReentrant(boolz)); + EXPECT_EQ("false", cfx_v8()->ToByteStringReentrant(boolz)); + EXPECT_EQ(L"false", cfx_v8()->ToWideStringReentrant(boolz)); + EXPECT_TRUE(cfx_v8()->ToObjectReentrant(boolz).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToArrayReentrant(boolz).IsEmpty()); } TEST_F(CFXV8UnitTest, NewNumber) { @@ -125,13 +126,13 @@ v8::Context::Scope context_scope(v8::Context::New(isolate())); auto num = cfx_v8()->NewNumber(42.1); - EXPECT_TRUE(cfx_v8()->ToBoolean(num)); - EXPECT_EQ(42, cfx_v8()->ToInt32(num)); - EXPECT_EQ(42.1, cfx_v8()->ToDouble(num)); - EXPECT_EQ("42.1", cfx_v8()->ToByteString(num)); - EXPECT_EQ(L"42.1", cfx_v8()->ToWideString(num)); - EXPECT_TRUE(cfx_v8()->ToObject(num).IsEmpty()); - EXPECT_TRUE(cfx_v8()->ToArray(num).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToBooleanReentrant(num)); + EXPECT_EQ(42, cfx_v8()->ToInt32Reentrant(num)); + EXPECT_EQ(42.1, cfx_v8()->ToDoubleReentrant(num)); + EXPECT_EQ("42.1", cfx_v8()->ToByteStringReentrant(num)); + EXPECT_EQ(L"42.1", cfx_v8()->ToWideStringReentrant(num)); + EXPECT_TRUE(cfx_v8()->ToObjectReentrant(num).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToArrayReentrant(num).IsEmpty()); } TEST_F(CFXV8UnitTest, NewString) { @@ -140,22 +141,22 @@ v8::Context::Scope context_scope(v8::Context::New(isolate())); auto str = cfx_v8()->NewString("123"); - EXPECT_TRUE(cfx_v8()->ToBoolean(str)); - EXPECT_EQ(123, cfx_v8()->ToInt32(str)); - EXPECT_EQ(123, cfx_v8()->ToDouble(str)); - EXPECT_EQ("123", cfx_v8()->ToByteString(str)); - EXPECT_EQ(L"123", cfx_v8()->ToWideString(str)); - EXPECT_TRUE(cfx_v8()->ToObject(str).IsEmpty()); - EXPECT_TRUE(cfx_v8()->ToArray(str).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToBooleanReentrant(str)); + EXPECT_EQ(123, cfx_v8()->ToInt32Reentrant(str)); + EXPECT_EQ(123, cfx_v8()->ToDoubleReentrant(str)); + EXPECT_EQ("123", cfx_v8()->ToByteStringReentrant(str)); + EXPECT_EQ(L"123", cfx_v8()->ToWideStringReentrant(str)); + EXPECT_TRUE(cfx_v8()->ToObjectReentrant(str).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToArrayReentrant(str).IsEmpty()); auto str2 = cfx_v8()->NewString(L"123"); - EXPECT_TRUE(cfx_v8()->ToBoolean(str2)); - EXPECT_EQ(123, cfx_v8()->ToInt32(str2)); - EXPECT_EQ(123, cfx_v8()->ToDouble(str2)); - EXPECT_EQ("123", cfx_v8()->ToByteString(str2)); - EXPECT_EQ(L"123", cfx_v8()->ToWideString(str2)); - EXPECT_TRUE(cfx_v8()->ToObject(str2).IsEmpty()); - EXPECT_TRUE(cfx_v8()->ToArray(str2).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToBooleanReentrant(str2)); + EXPECT_EQ(123, cfx_v8()->ToInt32Reentrant(str2)); + EXPECT_EQ(123, cfx_v8()->ToDoubleReentrant(str2)); + EXPECT_EQ("123", cfx_v8()->ToByteStringReentrant(str2)); + EXPECT_EQ(L"123", cfx_v8()->ToWideStringReentrant(str2)); + EXPECT_TRUE(cfx_v8()->ToObjectReentrant(str2).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToArrayReentrant(str2).IsEmpty()); } TEST_F(CFXV8UnitTest, NewDate) { @@ -164,13 +165,14 @@ v8::Context::Scope context_scope(v8::Context::New(isolate())); auto date = cfx_v8()->NewDate(1111111111); - EXPECT_TRUE(cfx_v8()->ToBoolean(date)); - EXPECT_EQ(1111111111, cfx_v8()->ToInt32(date)); - EXPECT_EQ(1111111111.0, cfx_v8()->ToDouble(date)); - EXPECT_NE("", cfx_v8()->ToByteString(date)); // exact format varies. - EXPECT_NE(L"", cfx_v8()->ToWideString(date)); // exact format varies. - EXPECT_TRUE(cfx_v8()->ToObject(date)->IsObject()); - EXPECT_TRUE(cfx_v8()->ToArray(date).IsEmpty()); + EXPECT_TRUE(cfx_v8()->ToBooleanReentrant(date)); + EXPECT_EQ(1111111111, cfx_v8()->ToInt32Reentrant(date)); + EXPECT_EQ(1111111111.0, cfx_v8()->ToDoubleReentrant(date)); + EXPECT_NE("", cfx_v8()->ToByteStringReentrant(date)); // exact format varies. + EXPECT_NE(L"", + cfx_v8()->ToWideStringReentrant(date)); // exact format varies. + EXPECT_TRUE(cfx_v8()->ToObjectReentrant(date)->IsObject()); + EXPECT_TRUE(cfx_v8()->ToArrayReentrant(date).IsEmpty()); } TEST_F(CFXV8UnitTest, NewArray) { @@ -180,24 +182,24 @@ auto array = cfx_v8()->NewArray(); EXPECT_EQ(0u, cfx_v8()->GetArrayLength(array)); - EXPECT_FALSE(cfx_v8()->GetArrayElement(array, 2).IsEmpty()); - EXPECT_TRUE(cfx_v8()->GetArrayElement(array, 2)->IsUndefined()); + EXPECT_FALSE(cfx_v8()->GetArrayElementReentrant(array, 2).IsEmpty()); + EXPECT_TRUE(cfx_v8()->GetArrayElementReentrant(array, 2)->IsUndefined()); EXPECT_EQ(0u, cfx_v8()->GetArrayLength(array)); - cfx_v8()->PutArrayElement(array, 3, cfx_v8()->NewNumber(12)); - EXPECT_FALSE(cfx_v8()->GetArrayElement(array, 2).IsEmpty()); - EXPECT_TRUE(cfx_v8()->GetArrayElement(array, 2)->IsUndefined()); - EXPECT_FALSE(cfx_v8()->GetArrayElement(array, 3).IsEmpty()); - EXPECT_TRUE(cfx_v8()->GetArrayElement(array, 3)->IsNumber()); + cfx_v8()->PutArrayElementReentrant(array, 3, cfx_v8()->NewNumber(12)); + EXPECT_FALSE(cfx_v8()->GetArrayElementReentrant(array, 2).IsEmpty()); + EXPECT_TRUE(cfx_v8()->GetArrayElementReentrant(array, 2)->IsUndefined()); + EXPECT_FALSE(cfx_v8()->GetArrayElementReentrant(array, 3).IsEmpty()); + EXPECT_TRUE(cfx_v8()->GetArrayElementReentrant(array, 3)->IsNumber()); EXPECT_EQ(4u, cfx_v8()->GetArrayLength(array)); - EXPECT_TRUE(cfx_v8()->ToBoolean(array)); - EXPECT_EQ(0, cfx_v8()->ToInt32(array)); - double d = cfx_v8()->ToDouble(array); + EXPECT_TRUE(cfx_v8()->ToBooleanReentrant(array)); + EXPECT_EQ(0, cfx_v8()->ToInt32Reentrant(array)); + double d = cfx_v8()->ToDoubleReentrant(array); EXPECT_NE(d, d); // i.e. NaN. - EXPECT_EQ(L",,,12", cfx_v8()->ToWideString(array)); - EXPECT_TRUE(cfx_v8()->ToObject(array)->IsObject()); - EXPECT_TRUE(cfx_v8()->ToArray(array)->IsArray()); + EXPECT_EQ(L",,,12", cfx_v8()->ToWideStringReentrant(array)); + EXPECT_TRUE(cfx_v8()->ToObjectReentrant(array)->IsObject()); + EXPECT_TRUE(cfx_v8()->ToArrayReentrant(array)->IsArray()); } TEST_F(CFXV8UnitTest, NewObject) { @@ -207,24 +209,27 @@ auto object = cfx_v8()->NewObject(); ASSERT_FALSE(object.IsEmpty()); - EXPECT_EQ(0u, cfx_v8()->GetObjectPropertyNames(object).size()); - EXPECT_FALSE(cfx_v8()->GetObjectProperty(object, "clams").IsEmpty()); - EXPECT_TRUE(cfx_v8()->GetObjectProperty(object, "clams")->IsUndefined()); - EXPECT_EQ(0u, cfx_v8()->GetObjectPropertyNames(object).size()); + EXPECT_EQ(0u, cfx_v8()->GetObjectPropertyNamesReentrant(object).size()); + EXPECT_FALSE(cfx_v8()->GetObjectPropertyReentrant(object, "clams").IsEmpty()); + EXPECT_TRUE( + cfx_v8()->GetObjectPropertyReentrant(object, "clams")->IsUndefined()); + EXPECT_EQ(0u, cfx_v8()->GetObjectPropertyNamesReentrant(object).size()); - cfx_v8()->PutObjectProperty(object, "clams", cfx_v8()->NewNumber(12)); - EXPECT_FALSE(cfx_v8()->GetObjectProperty(object, "clams").IsEmpty()); - EXPECT_TRUE(cfx_v8()->GetObjectProperty(object, "clams")->IsNumber()); - EXPECT_EQ(1u, cfx_v8()->GetObjectPropertyNames(object).size()); - EXPECT_EQ(L"clams", cfx_v8()->GetObjectPropertyNames(object)[0]); + cfx_v8()->PutObjectPropertyReentrant(object, "clams", + cfx_v8()->NewNumber(12)); + EXPECT_FALSE(cfx_v8()->GetObjectPropertyReentrant(object, "clams").IsEmpty()); + EXPECT_TRUE( + cfx_v8()->GetObjectPropertyReentrant(object, "clams")->IsNumber()); + EXPECT_EQ(1u, cfx_v8()->GetObjectPropertyNamesReentrant(object).size()); + EXPECT_EQ(L"clams", cfx_v8()->GetObjectPropertyNamesReentrant(object)[0]); - EXPECT_TRUE(cfx_v8()->ToBoolean(object)); - EXPECT_EQ(0, cfx_v8()->ToInt32(object)); - double d = cfx_v8()->ToDouble(object); + EXPECT_TRUE(cfx_v8()->ToBooleanReentrant(object)); + EXPECT_EQ(0, cfx_v8()->ToInt32Reentrant(object)); + double d = cfx_v8()->ToDoubleReentrant(object); EXPECT_NE(d, d); // i.e. NaN. - EXPECT_EQ(L"[object Object]", cfx_v8()->ToWideString(object)); - EXPECT_TRUE(cfx_v8()->ToObject(object)->IsObject()); - EXPECT_TRUE(cfx_v8()->ToArray(object).IsEmpty()); + EXPECT_EQ(L"[object Object]", cfx_v8()->ToWideStringReentrant(object)); + EXPECT_TRUE(cfx_v8()->ToObjectReentrant(object)->IsObject()); + EXPECT_TRUE(cfx_v8()->ToArrayReentrant(object).IsEmpty()); } TEST_F(CFXV8UnitTest, ThrowFromGetter) { @@ -245,7 +250,7 @@ }) .FromJust()); getter_sentinel = false; - EXPECT_TRUE(cfx_v8()->GetObjectProperty(object, "clams").IsEmpty()); + EXPECT_TRUE(cfx_v8()->GetObjectPropertyReentrant(object, "clams").IsEmpty()); EXPECT_TRUE(getter_sentinel); } @@ -268,6 +273,6 @@ }) .FromJust()); setter_sentinel = false; - cfx_v8()->PutObjectProperty(object, "clams", name); + cfx_v8()->PutObjectPropertyReentrant(object, "clams", name); EXPECT_TRUE(setter_sentinel); }
diff --git a/fxjs/cfxjs_engine_embeddertest.cpp b/fxjs/cfxjs_engine_embeddertest.cpp index 32188e6..7a079a9 100644 --- a/fxjs/cfxjs_engine_embeddertest.cpp +++ b/fxjs/cfxjs_engine_embeddertest.cpp
@@ -30,9 +30,10 @@ double expected) { v8::Context::Scope context_scope(current_engine->GetV8Context()); v8::Local<v8::Object> This = current_engine->GetThisObj(); - v8::Local<v8::Value> fred = current_engine->GetObjectProperty(This, "fred"); + v8::Local<v8::Value> fred = + current_engine->GetObjectPropertyReentrant(This, "fred"); EXPECT_TRUE(fred->IsNumber()); - EXPECT_EQ(expected, current_engine->ToDouble(fred)); + EXPECT_EQ(expected, current_engine->ToDoubleReentrant(fred)); } TEST_F(CFXJSEngineEmbedderTest, Getters) {
diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp index 3a73ba3..4251e62 100644 --- a/fxjs/cjs_annot.cpp +++ b/fxjs/cjs_annot.cpp
@@ -54,7 +54,7 @@ CJS_Result CJS_Annot::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { // May invalidate annot_. - bool bHidden = pRuntime->ToBoolean(vp); + bool bHidden = pRuntime->ToBooleanReentrant(vp); CPDFSDK_BAAnnot* pBAAnnot = annot_.Get(); if (!pBAAnnot) { @@ -89,7 +89,7 @@ CJS_Result CJS_Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { // May invalidate annot_. - WideString annotName = pRuntime->ToWideString(vp); + WideString annotName = pRuntime->ToWideStringReentrant(vp); CPDFSDK_BAAnnot* pBAAnnot = annot_.Get(); if (!pBAAnnot) {
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp index f2b7d6e..4679721 100644 --- a/fxjs/cjs_app.cpp +++ b/fxjs/cjs_app.cpp
@@ -103,7 +103,7 @@ return CJS_Result::Failure(JSMessage::kObjectTypeError); } v8::Local<v8::Array> aDocs = pRuntime->NewArray(); - pRuntime->PutArrayElement(aDocs, 0, pJSDocument->ToV8Object()); + pRuntime->PutArrayElementReentrant(aDocs, 0, pJSDocument->ToV8Object()); if (pRuntime->GetArrayLength(aDocs) > 0) { return CJS_Result::Success(aDocs); } @@ -122,7 +122,7 @@ CJS_Result CJS_App::set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - calculate_ = pRuntime->ToBoolean(vp); + calculate_ = pRuntime->ToBooleanReentrant(vp); pRuntime->GetFormFillEnv()->GetInteractiveForm()->EnableCalculate(calculate_); return CJS_Result::Success(); } @@ -237,33 +237,34 @@ WideString swMsg; if (newParams[0]->IsArray()) { - v8::Local<v8::Array> carray = pRuntime->ToArray(newParams[0]); + v8::Local<v8::Array> carray = pRuntime->ToArrayReentrant(newParams[0]); swMsg = L"["; for (size_t i = 0; i < pRuntime->GetArrayLength(carray); ++i) { if (i) { swMsg += L", "; } - swMsg += pRuntime->ToWideString(pRuntime->GetArrayElement(carray, i)); + swMsg += pRuntime->ToWideStringReentrant( + pRuntime->GetArrayElementReentrant(carray, i)); } swMsg += L"]"; } else { - swMsg = pRuntime->ToWideString(newParams[0]); + swMsg = pRuntime->ToWideStringReentrant(newParams[0]); } int iIcon = JSPLATFORM_ALERT_ICON_DEFAULT; if (IsExpandedParamKnown(newParams[1])) { - iIcon = pRuntime->ToInt32(newParams[1]); + iIcon = pRuntime->ToInt32Reentrant(newParams[1]); } int iType = JSPLATFORM_ALERT_BUTTON_DEFAULT; if (IsExpandedParamKnown(newParams[2])) { - iType = pRuntime->ToInt32(newParams[2]); + iType = pRuntime->ToInt32Reentrant(newParams[2]); } WideString swTitle; if (IsExpandedParamKnown(newParams[3])) { - swTitle = pRuntime->ToWideString(newParams[3]); + swTitle = pRuntime->ToWideStringReentrant(newParams[3]); } else { swTitle = JSGetStringFromID(JSMessage::kAlert); } @@ -285,7 +286,7 @@ int type = JSPLATFORM_BEEP_DEFAULT; if (IsExpandedParamKnown(params[0])) { - type = pRuntime->ToInt32(params[0]); + type = pRuntime->ToInt32Reentrant(params[0]); } pRuntime->GetFormFillEnv()->JS_appBeep(type); @@ -316,12 +317,14 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString script = pRuntime->ToWideString(params[0]); + WideString script = pRuntime->ToWideStringReentrant(params[0]); + if (script.IsEmpty()) { return CJS_Result::Failure(JSMessage::kInvalidInputError); } - uint32_t dwInterval = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000; + uint32_t dwInterval = + params.size() > 1 ? pRuntime->ToInt32Reentrant(params[1]) : 1000; auto timerRef = std::make_unique<GlobalTimer>( this, pRuntime, GlobalTimer::Type::kRepeating, script, dwInterval, 0); GlobalTimer* pTimerRef = timerRef.get(); @@ -346,12 +349,13 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString script = pRuntime->ToWideString(params[0]); + WideString script = pRuntime->ToWideStringReentrant(params[0]); if (script.IsEmpty()) { return CJS_Result::Failure(JSMessage::kInvalidInputError); } - uint32_t dwTimeOut = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000; + uint32_t dwTimeOut = + params.size() > 1 ? pRuntime->ToInt32Reentrant(params[1]) : 1000; auto timerRef = std::make_unique<GlobalTimer>(this, pRuntime, GlobalTimer::Type::kOneShot, script, dwTimeOut, dwTimeOut); @@ -397,7 +401,7 @@ return; } - v8::Local<v8::Object> pObj = pRuntime->ToObject(param); + v8::Local<v8::Object> pObj = pRuntime->ToObjectReentrant(param); auto pTimer = JSGetObject<CJS_TimerObj>(pRuntime->GetIsolate(), pObj); if (!pTimer) { return; @@ -457,10 +461,10 @@ return CJS_Result::Failure(JSMessage::kParamError); } - bool bUI = pRuntime->ToBoolean(newParams[0]); + bool bUI = pRuntime->ToBooleanReentrant(newParams[0]); WideString cTo; if (IsExpandedParamKnown(newParams[1])) { - cTo = pRuntime->ToWideString(newParams[1]); + cTo = pRuntime->ToWideStringReentrant(newParams[1]); } else { // cTo parameter required when UI not invoked. if (!bUI) { @@ -470,22 +474,22 @@ WideString cCc; if (IsExpandedParamKnown(newParams[2])) { - cCc = pRuntime->ToWideString(newParams[2]); + cCc = pRuntime->ToWideStringReentrant(newParams[2]); } WideString cBcc; if (IsExpandedParamKnown(newParams[3])) { - cBcc = pRuntime->ToWideString(newParams[3]); + cBcc = pRuntime->ToWideStringReentrant(newParams[3]); } WideString cSubject; if (IsExpandedParamKnown(newParams[4])) { - cSubject = pRuntime->ToWideString(newParams[4]); + cSubject = pRuntime->ToWideStringReentrant(newParams[4]); } WideString cMsg; if (IsExpandedParamKnown(newParams[5])) { - cMsg = pRuntime->ToWideString(newParams[5]); + cMsg = pRuntime->ToWideStringReentrant(newParams[5]); } pRuntime->BeginBlock(); @@ -507,7 +511,7 @@ CJS_Result CJS_App::set_runtime_highlight(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - runtime_high_light_ = pRuntime->ToBoolean(vp); + runtime_high_light_ = pRuntime->ToBooleanReentrant(vp); return CJS_Result::Success(); } @@ -561,25 +565,22 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString swQuestion = pRuntime->ToWideString(newParams[0]); + WideString swQuestion = pRuntime->ToWideStringReentrant(newParams[0]); auto swTitle = WideString::FromASCII("PDF"); if (IsExpandedParamKnown(newParams[1])) { - swTitle = pRuntime->ToWideString(newParams[1]); + swTitle = pRuntime->ToWideStringReentrant(newParams[1]); } - WideString swDefault; if (IsExpandedParamKnown(newParams[2])) { - swDefault = pRuntime->ToWideString(newParams[2]); + swDefault = pRuntime->ToWideStringReentrant(newParams[2]); } - bool bPassword = false; if (IsExpandedParamKnown(newParams[3])) { - bPassword = pRuntime->ToBoolean(newParams[3]); + bPassword = pRuntime->ToBooleanReentrant(newParams[3]); } - WideString swLabel; if (IsExpandedParamKnown(newParams[4])) { - swLabel = pRuntime->ToWideString(newParams[4]); + swLabel = pRuntime->ToWideStringReentrant(newParams[4]); } static constexpr int kMaxWideChars = 1024;
diff --git a/fxjs/cjs_color.cpp b/fxjs/cjs_color.cpp index 455b45b..b0c0dc0 100644 --- a/fxjs/cjs_color.cpp +++ b/fxjs/cjs_color.cpp
@@ -57,27 +57,35 @@ switch (color.nColorType) { case CFX_Color::Type::kTransparent: array = pRuntime->NewArray(); - pRuntime->PutArrayElement(array, 0, pRuntime->NewString("T")); + pRuntime->PutArrayElementReentrant(array, 0, pRuntime->NewString("T")); break; case CFX_Color::Type::kGray: array = pRuntime->NewArray(); - pRuntime->PutArrayElement(array, 0, pRuntime->NewString("G")); - pRuntime->PutArrayElement(array, 1, pRuntime->NewNumber(color.fColor1)); + pRuntime->PutArrayElementReentrant(array, 0, pRuntime->NewString("G")); + pRuntime->PutArrayElementReentrant(array, 1, + pRuntime->NewNumber(color.fColor1)); break; case CFX_Color::Type::kRGB: array = pRuntime->NewArray(); - pRuntime->PutArrayElement(array, 0, pRuntime->NewString("RGB")); - pRuntime->PutArrayElement(array, 1, pRuntime->NewNumber(color.fColor1)); - pRuntime->PutArrayElement(array, 2, pRuntime->NewNumber(color.fColor2)); - pRuntime->PutArrayElement(array, 3, pRuntime->NewNumber(color.fColor3)); + pRuntime->PutArrayElementReentrant(array, 0, pRuntime->NewString("RGB")); + pRuntime->PutArrayElementReentrant(array, 1, + pRuntime->NewNumber(color.fColor1)); + pRuntime->PutArrayElementReentrant(array, 2, + pRuntime->NewNumber(color.fColor2)); + pRuntime->PutArrayElementReentrant(array, 3, + pRuntime->NewNumber(color.fColor3)); break; case CFX_Color::Type::kCMYK: array = pRuntime->NewArray(); - pRuntime->PutArrayElement(array, 0, pRuntime->NewString("CMYK")); - pRuntime->PutArrayElement(array, 1, pRuntime->NewNumber(color.fColor1)); - pRuntime->PutArrayElement(array, 2, pRuntime->NewNumber(color.fColor2)); - pRuntime->PutArrayElement(array, 3, pRuntime->NewNumber(color.fColor3)); - pRuntime->PutArrayElement(array, 4, pRuntime->NewNumber(color.fColor4)); + pRuntime->PutArrayElementReentrant(array, 0, pRuntime->NewString("CMYK")); + pRuntime->PutArrayElementReentrant(array, 1, + pRuntime->NewNumber(color.fColor1)); + pRuntime->PutArrayElementReentrant(array, 2, + pRuntime->NewNumber(color.fColor2)); + pRuntime->PutArrayElementReentrant(array, 3, + pRuntime->NewNumber(color.fColor3)); + pRuntime->PutArrayElementReentrant(array, 4, + pRuntime->NewNumber(color.fColor4)); break; } return array; @@ -91,16 +99,16 @@ return CFX_Color(); } - WideString sSpace = - pRuntime->ToWideString(pRuntime->GetArrayElement(array, 0)); + WideString sSpace = pRuntime->ToWideStringReentrant( + pRuntime->GetArrayElementReentrant(array, 0)); if (sSpace.EqualsASCII("T")) { return CFX_Color(CFX_Color::Type::kTransparent); } float d1 = 0; if (nArrayLen > 1) { - d1 = static_cast<float>( - pRuntime->ToDouble(pRuntime->GetArrayElement(array, 1))); + d1 = static_cast<float>(pRuntime->ToDoubleReentrant( + pRuntime->GetArrayElementReentrant(array, 1))); } if (sSpace.EqualsASCII("G")) { return CFX_Color(CFX_Color::Type::kGray, d1); @@ -109,12 +117,12 @@ float d2 = 0; float d3 = 0; if (nArrayLen > 2) { - d2 = static_cast<float>( - pRuntime->ToDouble(pRuntime->GetArrayElement(array, 2))); + d2 = static_cast<float>(pRuntime->ToDoubleReentrant( + pRuntime->GetArrayElementReentrant(array, 2))); } if (nArrayLen > 3) { - d3 = static_cast<float>( - pRuntime->ToDouble(pRuntime->GetArrayElement(array, 3))); + d3 = static_cast<float>(pRuntime->ToDoubleReentrant( + pRuntime->GetArrayElementReentrant(array, 3))); } if (sSpace.EqualsASCII("RGB")) { return CFX_Color(CFX_Color::Type::kRGB, d1, d2, d3); @@ -122,8 +130,8 @@ float d4 = 0; if (nArrayLen > 4) { - d4 = static_cast<float>( - pRuntime->ToDouble(pRuntime->GetArrayElement(array, 4))); + d4 = static_cast<float>(pRuntime->ToDoubleReentrant( + pRuntime->GetArrayElementReentrant(array, 4))); } if (sSpace.EqualsASCII("CMYK")) { return CFX_Color(CFX_Color::Type::kCMYK, d1, d2, d3, d4); @@ -273,7 +281,7 @@ return CJS_Result::Failure(JSMessage::kTypeError); } - *var = ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(vp)); + *var = ConvertArrayToPWLColor(pRuntime, pRuntime->ToArrayReentrant(vp)); return CJS_Result::Success(); } @@ -287,7 +295,7 @@ return CJS_Result::Failure(JSMessage::kTypeError); } - WideString sDestSpace = pRuntime->ToWideString(params[1]); + WideString sDestSpace = pRuntime->ToWideStringReentrant(params[1]); CFX_Color::Type nColorType = CFX_Color::Type::kTransparent; if (sDestSpace.EqualsASCII("T")) { nColorType = CFX_Color::Type::kTransparent; @@ -300,7 +308,7 @@ } CFX_Color color = - ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(params[0])); + ConvertArrayToPWLColor(pRuntime, pRuntime->ToArrayReentrant(params[0])); v8::Local<v8::Value> array = ConvertPWLColorToArray(pRuntime, color.ConvertColorType(nColorType)); if (array.IsEmpty()) { @@ -321,9 +329,9 @@ } CFX_Color color1 = - ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(params[0])); + ConvertArrayToPWLColor(pRuntime, pRuntime->ToArrayReentrant(params[0])); CFX_Color color2 = - ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(params[1])); + ConvertArrayToPWLColor(pRuntime, pRuntime->ToArrayReentrant(params[1])); // Relies on higher values having more components. CFX_Color::Type best = std::max(color1.nColorType, color2.nColorType);
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp index 2b0b4fb..0b8e0f9 100644 --- a/fxjs/cjs_document.cpp +++ b/fxjs/cjs_document.cpp
@@ -170,8 +170,8 @@ return CJS_Result::Failure(JSMessage::kBadObjectError); } - pRuntime->ToBoolean(vp) ? form_fill_env_->SetChangeMark() - : form_fill_env_->ClearChangeMark(); + pRuntime->ToBooleanReentrant(vp) ? form_fill_env_->SetChangeMark() + : form_fill_env_->ClearChangeMark(); return CJS_Result::Success(); } @@ -204,7 +204,7 @@ } int iPageCount = form_fill_env_->GetPageCount(); - int iPageNum = pRuntime->ToInt32(vp); + int iPageNum = pRuntime->ToInt32Reentrant(vp); if (iPageNum >= 0 && iPageNum < iPageCount) { form_fill_env_->JS_docgotoPage(iPageNum); } else if (iPageNum >= iPageCount) { @@ -259,7 +259,7 @@ return CJS_Result::Failure(JSMessage::kBadObjectError); } - WideString wideName = pRuntime->ToWideString(params[0]); + WideString wideName = pRuntime->ToWideStringReentrant(params[0]); CPDF_InteractiveForm* pPDFForm = GetCoreInteractiveForm(); if (pPDFForm->CountFields(wideName) <= 0) { return CJS_Result::Success(pRuntime->NewUndefined()); @@ -292,7 +292,7 @@ return CJS_Result::Failure(JSMessage::kBadObjectError); } - int nIndex = pRuntime->ToInt32(params[0]); + int nIndex = pRuntime->ToInt32Reentrant(params[0]); if (nIndex < 0) { return CJS_Result::Failure(JSMessage::kValueError); } @@ -338,32 +338,32 @@ bool bUI = true; if (IsExpandedParamKnown(newParams[0])) { - bUI = pRuntime->ToBoolean(newParams[0]); + bUI = pRuntime->ToBooleanReentrant(newParams[0]); } WideString cTo; if (IsExpandedParamKnown(newParams[1])) { - cTo = pRuntime->ToWideString(newParams[1]); + cTo = pRuntime->ToWideStringReentrant(newParams[1]); } WideString cCc; if (IsExpandedParamKnown(newParams[2])) { - cCc = pRuntime->ToWideString(newParams[2]); + cCc = pRuntime->ToWideStringReentrant(newParams[2]); } WideString cBcc; if (IsExpandedParamKnown(newParams[3])) { - cBcc = pRuntime->ToWideString(newParams[3]); + cBcc = pRuntime->ToWideStringReentrant(newParams[3]); } WideString cSubject; if (IsExpandedParamKnown(newParams[4])) { - cSubject = pRuntime->ToWideString(newParams[4]); + cSubject = pRuntime->ToWideStringReentrant(newParams[4]); } WideString cMsg; if (IsExpandedParamKnown(newParams[5])) { - cMsg = pRuntime->ToWideString(newParams[5]); + cMsg = pRuntime->ToWideStringReentrant(newParams[5]); } pRuntime->BeginBlock(); @@ -398,32 +398,32 @@ bool bUI = true; if (IsExpandedParamKnown(newParams[0])) { - bUI = pRuntime->ToBoolean(newParams[0]); + bUI = pRuntime->ToBooleanReentrant(newParams[0]); } WideString cTo; if (IsExpandedParamKnown(newParams[1])) { - cTo = pRuntime->ToWideString(newParams[1]); + cTo = pRuntime->ToWideStringReentrant(newParams[1]); } WideString cCc; if (IsExpandedParamKnown(newParams[2])) { - cCc = pRuntime->ToWideString(newParams[2]); + cCc = pRuntime->ToWideStringReentrant(newParams[2]); } WideString cBcc; if (IsExpandedParamKnown(newParams[3])) { - cBcc = pRuntime->ToWideString(newParams[3]); + cBcc = pRuntime->ToWideStringReentrant(newParams[3]); } WideString cSubject; if (IsExpandedParamKnown(newParams[4])) { - cSubject = pRuntime->ToWideString(newParams[4]); + cSubject = pRuntime->ToWideStringReentrant(newParams[4]); } WideString cMsg; if (IsExpandedParamKnown(newParams[5])) { - cMsg = pRuntime->ToWideString(newParams[5]); + cMsg = pRuntime->ToWideStringReentrant(newParams[5]); } pRuntime->BeginBlock(); @@ -441,42 +441,42 @@ bool bUI = true; if (IsExpandedParamKnown(newParams[0])) { - bUI = pRuntime->ToBoolean(newParams[0]); + bUI = pRuntime->ToBooleanReentrant(newParams[0]); } int nStart = 0; if (IsExpandedParamKnown(newParams[1])) { - nStart = pRuntime->ToInt32(newParams[1]); + nStart = pRuntime->ToInt32Reentrant(newParams[1]); } int nEnd = 0; if (IsExpandedParamKnown(newParams[2])) { - nEnd = pRuntime->ToInt32(newParams[2]); + nEnd = pRuntime->ToInt32Reentrant(newParams[2]); } bool bSilent = false; if (IsExpandedParamKnown(newParams[3])) { - bSilent = pRuntime->ToBoolean(newParams[3]); + bSilent = pRuntime->ToBooleanReentrant(newParams[3]); } bool bShrinkToFit = false; if (IsExpandedParamKnown(newParams[4])) { - bShrinkToFit = pRuntime->ToBoolean(newParams[4]); + bShrinkToFit = pRuntime->ToBooleanReentrant(newParams[4]); } bool bPrintAsImage = false; if (IsExpandedParamKnown(newParams[5])) { - bPrintAsImage = pRuntime->ToBoolean(newParams[5]); + bPrintAsImage = pRuntime->ToBooleanReentrant(newParams[5]); } bool bReverse = false; if (IsExpandedParamKnown(newParams[6])) { - bReverse = pRuntime->ToBoolean(newParams[6]); + bReverse = pRuntime->ToBooleanReentrant(newParams[6]); } bool bAnnotations = false; if (IsExpandedParamKnown(newParams[7])) { - bAnnotations = pRuntime->ToBoolean(newParams[7]); + bAnnotations = pRuntime->ToBooleanReentrant(newParams[7]); } if (!form_fill_env_) { @@ -512,7 +512,7 @@ return CJS_Result::Failure(JSMessage::kPermissionError); } - WideString sFieldName = pRuntime->ToWideString(params[0]); + WideString sFieldName = pRuntime->ToWideStringReentrant(params[0]); CPDFSDK_InteractiveForm* pInteractiveForm = GetSDKInteractiveForm(); std::vector<ObservedPtr<CPDFSDK_Widget>> widgets; pInteractiveForm->GetWidgets(sFieldName, &widgets); @@ -573,15 +573,15 @@ v8::Local<v8::Array> array; if (params[0]->IsString()) { array = pRuntime->NewArray(); - pRuntime->PutArrayElement(array, 0, params[0]); + pRuntime->PutArrayElementReentrant(array, 0, params[0]); } else { - array = pRuntime->ToArray(params[0]); + array = pRuntime->ToArrayReentrant(params[0]); } std::vector<CPDF_FormField*> aFields; for (size_t i = 0; i < pRuntime->GetArrayLength(array); ++i) { - WideString swVal = - pRuntime->ToWideString(pRuntime->GetArrayElement(array, i)); + WideString swVal = pRuntime->ToWideStringReentrant( + pRuntime->GetArrayElementReentrant(array, i)); const size_t jsz = pPDFForm->CountFields(swVal); for (size_t j = 0; j < jsz; ++j) { aFields.push_back(pPDFForm->GetField(j, swVal)); @@ -628,26 +628,30 @@ bool bFDF = true; bool bEmpty = false; if (params[0]->IsString()) { - strURL = pRuntime->ToWideString(params[0]); + strURL = pRuntime->ToWideStringReentrant(params[0]); if (nSize > 1) { - bFDF = pRuntime->ToBoolean(params[1]); + bFDF = pRuntime->ToBooleanReentrant(params[1]); } if (nSize > 2) { - bEmpty = pRuntime->ToBoolean(params[2]); + bEmpty = pRuntime->ToBooleanReentrant(params[2]); } if (nSize > 3) { - aFields = pRuntime->ToArray(params[3]); + aFields = pRuntime->ToArrayReentrant(params[3]); } } else if (params[0]->IsObject()) { - v8::Local<v8::Object> pObj = pRuntime->ToObject(params[0]); - v8::Local<v8::Value> pValue = pRuntime->GetObjectProperty(pObj, "cURL"); + v8::Local<v8::Object> pObj = pRuntime->ToObjectReentrant(params[0]); + v8::Local<v8::Value> pValue = + pRuntime->GetObjectPropertyReentrant(pObj, "cURL"); if (!pValue.IsEmpty()) { - strURL = pRuntime->ToWideString(pValue); + strURL = pRuntime->ToWideStringReentrant(pValue); } - bFDF = pRuntime->ToBoolean(pRuntime->GetObjectProperty(pObj, "bFDF")); - bEmpty = pRuntime->ToBoolean(pRuntime->GetObjectProperty(pObj, "bEmpty")); - aFields = pRuntime->ToArray(pRuntime->GetObjectProperty(pObj, "aFields")); + bFDF = pRuntime->ToBooleanReentrant( + pRuntime->GetObjectPropertyReentrant(pObj, "bFDF")); + bEmpty = pRuntime->ToBooleanReentrant( + pRuntime->GetObjectPropertyReentrant(pObj, "bEmpty")); + aFields = pRuntime->ToArrayReentrant( + pRuntime->GetObjectPropertyReentrant(pObj, "aFields")); } CPDF_InteractiveForm* pPDFForm = GetCoreInteractiveForm(); @@ -662,8 +666,8 @@ std::vector<CPDF_FormField*> fieldObjects; for (size_t i = 0; i < pRuntime->GetArrayLength(aFields); ++i) { - WideString sName = - pRuntime->ToWideString(pRuntime->GetArrayElement(aFields, i)); + WideString sName = pRuntime->ToWideStringReentrant( + pRuntime->GetArrayElementReentrant(aFields, i)); const size_t jsz = pPDFForm->CountFields(sName); for (size_t j = 0; j < jsz; ++j) { CPDF_FormField* pField = pPDFForm->GetField(j, sName); @@ -728,24 +732,24 @@ WideString cwTrapped = dict->GetUnicodeTextFor("Trapped"); v8::Local<v8::Object> pObj = pRuntime->NewObject(); - pRuntime->PutObjectProperty(pObj, "Author", - pRuntime->NewString(cwAuthor.AsStringView())); - pRuntime->PutObjectProperty(pObj, "Title", - pRuntime->NewString(cwTitle.AsStringView())); - pRuntime->PutObjectProperty(pObj, "Subject", - pRuntime->NewString(cwSubject.AsStringView())); - pRuntime->PutObjectProperty(pObj, "Keywords", - pRuntime->NewString(cwKeywords.AsStringView())); - pRuntime->PutObjectProperty(pObj, "Creator", - pRuntime->NewString(cwCreator.AsStringView())); - pRuntime->PutObjectProperty(pObj, "Producer", - pRuntime->NewString(cwProducer.AsStringView())); - pRuntime->PutObjectProperty( + pRuntime->PutObjectPropertyReentrant( + pObj, "Author", pRuntime->NewString(cwAuthor.AsStringView())); + pRuntime->PutObjectPropertyReentrant( + pObj, "Title", pRuntime->NewString(cwTitle.AsStringView())); + pRuntime->PutObjectPropertyReentrant( + pObj, "Subject", pRuntime->NewString(cwSubject.AsStringView())); + pRuntime->PutObjectPropertyReentrant( + pObj, "Keywords", pRuntime->NewString(cwKeywords.AsStringView())); + pRuntime->PutObjectPropertyReentrant( + pObj, "Creator", pRuntime->NewString(cwCreator.AsStringView())); + pRuntime->PutObjectPropertyReentrant( + pObj, "Producer", pRuntime->NewString(cwProducer.AsStringView())); + pRuntime->PutObjectPropertyReentrant( pObj, "CreationDate", pRuntime->NewString(cwCreationDate.AsStringView())); - pRuntime->PutObjectProperty(pObj, "ModDate", - pRuntime->NewString(cwModDate.AsStringView())); - pRuntime->PutObjectProperty(pObj, "Trapped", - pRuntime->NewString(cwTrapped.AsStringView())); + pRuntime->PutObjectPropertyReentrant( + pObj, "ModDate", pRuntime->NewString(cwModDate.AsStringView())); + pRuntime->PutObjectPropertyReentrant( + pObj, "Trapped", pRuntime->NewString(cwTrapped.AsStringView())); // PutObjectProperty() calls below may re-enter JS and change info dict. CPDF_DictionaryLocker locker(ToDictionary(dict->Clone())); @@ -753,14 +757,15 @@ const ByteString& bsKey = it.first; const RetainPtr<CPDF_Object>& pValueObj = it.second; if (pValueObj->IsString() || pValueObj->IsName()) { - pRuntime->PutObjectProperty( + pRuntime->PutObjectPropertyReentrant( pObj, bsKey.AsStringView(), pRuntime->NewString(pValueObj->GetUnicodeText().AsStringView())); } else if (pValueObj->IsNumber()) { - pRuntime->PutObjectProperty(pObj, bsKey.AsStringView(), - pRuntime->NewNumber(pValueObj->GetNumber())); + pRuntime->PutObjectPropertyReentrant( + pObj, bsKey.AsStringView(), + pRuntime->NewNumber(pValueObj->GetNumber())); } else if (pValueObj->IsBoolean()) { - pRuntime->PutObjectProperty( + pRuntime->PutObjectPropertyReentrant( pObj, bsKey.AsStringView(), pRuntime->NewBoolean(!!pValueObj->GetInteger())); } @@ -826,7 +831,7 @@ return CJS_Result::Failure(JSMessage::kPermissionError); } - delay_ = pRuntime->ToBoolean(vp); + delay_ = pRuntime->ToBooleanReentrant(vp); if (delay_) { delay_data_.clear(); return CJS_Result::Success(); @@ -963,7 +968,7 @@ CJS_Result CJS_Document::set_base_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - base_url_ = pRuntime->ToWideString(vp); + base_url_ = pRuntime->ToWideStringReentrant(vp); return CJS_Result::Success(); } @@ -984,7 +989,7 @@ } CPDFSDK_InteractiveForm* pInteractiveForm = GetSDKInteractiveForm(); - pInteractiveForm->EnableCalculate(pRuntime->ToBoolean(vp)); + pInteractiveForm->EnableCalculate(pRuntime->ToBooleanReentrant(vp)); return CJS_Result::Success(); } @@ -1068,8 +1073,8 @@ return CJS_Result::Failure(JSMessage::kBadObjectError); } - int nPageNo = pRuntime->ToInt32(params[0]); - WideString swAnnotName = pRuntime->ToWideString(params[1]); + int nPageNo = pRuntime->ToInt32Reentrant(params[0]); + WideString swAnnotName = pRuntime->ToWideStringReentrant(params[1]); CPDFSDK_PageView* pPageView = form_fill_env_->GetPageViewAtIndex(nPageNo); if (!pPageView) { return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -1141,7 +1146,7 @@ auto* pJS_Annot = static_cast<CJS_Annot*>( CFXJS_Engine::GetBinding(pRuntime->GetIsolate(), pObj)); pJS_Annot->SetSDKAnnot(pSDKAnnotCur->AsBAAnnot()); - pRuntime->PutArrayElement( + pRuntime->PutArrayElementReentrant( annots, annots->Length(), pJS_Annot ? v8::Local<v8::Value>(pJS_Annot->ToV8Object()) : v8::Local<v8::Value>()); @@ -1181,12 +1186,12 @@ return CJS_Result::Failure(JSMessage::kTypeError); } - v8::Local<v8::Object> pObj = pRuntime->ToObject(params[1]); + v8::Local<v8::Object> pObj = pRuntime->ToObjectReentrant(params[1]); if (!JSGetObject<CJS_Icon>(pRuntime->GetIsolate(), pObj)) { return CJS_Result::Failure(JSMessage::kTypeError); } - WideString swIconName = pRuntime->ToWideString(params[0]); + WideString swIconName = pRuntime->ToWideStringReentrant(params[0]); icon_names_.push_back(swIconName); return CJS_Result::Success(); } @@ -1210,10 +1215,10 @@ auto* pJS_Icon = static_cast<CJS_Icon*>( CFXJS_Engine::GetBinding(pRuntime->GetIsolate(), pObj)); pJS_Icon->SetIconName(name); - pRuntime->PutArrayElement(Icons, i++, - pJS_Icon - ? v8::Local<v8::Value>(pJS_Icon->ToV8Object()) - : v8::Local<v8::Value>()); + pRuntime->PutArrayElementReentrant( + Icons, i++, + pJS_Icon ? v8::Local<v8::Value>(pJS_Icon->ToV8Object()) + : v8::Local<v8::Value>()); } return CJS_Result::Success(Icons); } @@ -1229,7 +1234,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString swIconName = pRuntime->ToWideString(params[0]); + WideString swIconName = pRuntime->ToWideStringReentrant(params[0]); auto it = std::ranges::find(icon_names_, swIconName); if (it == icon_names_.end()) { return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -1314,9 +1319,10 @@ // TODO(tsepez): check maximum allowable params. - int nPageNo = params.size() > 0 ? pRuntime->ToInt32(params[0]) : 0; - int nWordNo = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 0; - bool bStrip = params.size() > 2 ? pRuntime->ToBoolean(params[2]) : true; + int nPageNo = params.size() > 0 ? pRuntime->ToInt32Reentrant(params[0]) : 0; + int nWordNo = params.size() > 1 ? pRuntime->ToInt32Reentrant(params[1]) : 0; + bool bStrip = + params.size() > 2 ? pRuntime->ToBooleanReentrant(params[2]) : true; CPDF_Document* document = form_fill_env_->GetPDFDocument(); if (nPageNo < 0 || nPageNo >= document->GetPageCount()) { @@ -1380,7 +1386,7 @@ return CJS_Result::Failure(JSMessage::kPermissionError); } - int nPageNo = params.size() > 0 ? pRuntime->ToInt32(params[0]) : 0; + int nPageNo = params.size() > 0 ? pRuntime->ToInt32Reentrant(params[0]) : 0; CPDF_Document* document = form_fill_env_->GetPDFDocument(); if (nPageNo < 0 || nPageNo >= document->GetPageCount()) { return CJS_Result::Failure(JSMessage::kValueError); @@ -1476,7 +1482,7 @@ CPDF_Document* document = form_fill_env_->GetPDFDocument(); RetainPtr<const CPDF_Array> dest_array = CPDF_NameTree::LookupNamedDest( - document, pRuntime->ToByteString(params[0])); + document, pRuntime->ToByteStringReentrant(params[0])); if (!dest_array) { return CJS_Result::Failure(JSMessage::kBadObjectError); }
diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp index 8674bc0..62e7e6e 100644 --- a/fxjs/cjs_event.cpp +++ b/fxjs/cjs_event.cpp
@@ -63,7 +63,7 @@ v8::Local<v8::Value> vp) { if (vp->IsString()) { CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext(); - pEvent->Change() = pRuntime->ToWideString(vp); + pEvent->Change() = pRuntime->ToWideStringReentrant(vp); } return CJS_Result::Success(); } @@ -138,7 +138,7 @@ CJS_Result CJS_Event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext(); - pEvent->Rc() = pRuntime->ToBoolean(vp); + pEvent->Rc() = pRuntime->ToBooleanReentrant(vp); return CJS_Result::Success(); } @@ -182,7 +182,7 @@ v8::Local<v8::Value> vp) { CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext(); if (pEvent->Name() == "Keystroke") { - pEvent->SetSelEnd(pRuntime->ToInt32(vp)); + pEvent->SetSelEnd(pRuntime->ToInt32Reentrant(vp)); } return CJS_Result::Success(); @@ -201,7 +201,7 @@ v8::Local<v8::Value> vp) { CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext(); if (pEvent->Name() == "Keystroke") { - pEvent->SetSelStart(pRuntime->ToInt32(vp)); + pEvent->SetSelStart(pRuntime->ToInt32Reentrant(vp)); } return CJS_Result::Success(); @@ -290,7 +290,7 @@ if (vp->IsNullOrUndefined() || vp->IsBoolean()) { return CJS_Result::Failure(JSMessage::kInvalidSetError); } - pEvent->Value() = pRuntime->ToWideString(vp); + pEvent->Value() = pRuntime->ToWideStringReentrant(vp); return CJS_Result::Success(); }
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp index d886c58..1d2acf3 100644 --- a/fxjs/cjs_field.cpp +++ b/fxjs/cjs_field.cpp
@@ -782,7 +782,7 @@ return CJS_Result::Failure(JSMessage::kReadOnlyError); } - ByteString byte_str = pRuntime->ToByteString(vp); + ByteString byte_str = pRuntime->ToByteStringReentrant(vp); if (delay_) { AddDelay_String(FP_BORDERSTYLE, byte_str); } else { @@ -1104,7 +1104,7 @@ v8::Local<v8::Array> SelArray = pRuntime->NewArray(); for (int i = 0; i < count; i++) { - pRuntime->PutArrayElement( + pRuntime->PutArrayElementReentrant( SelArray, i, pRuntime->NewNumber(pFormField->GetSelectedIndex(i))); } if (SelArray.IsEmpty()) { @@ -1121,12 +1121,12 @@ std::vector<uint32_t> array; if (vp->IsNumber()) { - array.push_back(pRuntime->ToInt32(vp)); + array.push_back(pRuntime->ToInt32Reentrant(vp)); } else if (fxv8::IsArray(vp)) { - v8::Local<v8::Array> SelArray = pRuntime->ToArray(vp); + v8::Local<v8::Array> SelArray = pRuntime->ToArrayReentrant(vp); for (size_t i = 0; i < pRuntime->GetArrayLength(SelArray); i++) { - array.push_back( - pRuntime->ToInt32(pRuntime->GetArrayElement(SelArray, i))); + array.push_back(pRuntime->ToInt32Reentrant( + pRuntime->GetArrayElementReentrant(SelArray, i))); } } @@ -1235,7 +1235,7 @@ return CJS_Result::Failure(JSMessage::kReadOnlyError); } - SetDelay(pRuntime->ToBoolean(vp)); + SetDelay(pRuntime->ToBooleanReentrant(vp)); return CJS_Result::Success(); } @@ -1271,7 +1271,7 @@ if (!can_set_) { return CJS_Result::Failure(JSMessage::kReadOnlyError); } - int value = pRuntime->ToInt32(vp); // Re-entrant. + int value = pRuntime->ToInt32Reentrant(vp); if (!form_fill_env_) { return CJS_Result::Failure(JSMessage::kBadObjectError); } @@ -1327,7 +1327,7 @@ if (form_control_index_ < 0) { for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { CPDF_FormControl* pFormControl = pFormField->GetControl(i); - pRuntime->PutArrayElement( + pRuntime->PutArrayElementReentrant( ExportValuesArray, i, pRuntime->NewString(pFormControl->GetExportValue().AsStringView())); } @@ -1342,7 +1342,7 @@ return CJS_Result::Failure(JSMessage::kBadObjectError); } - pRuntime->PutArrayElement( + pRuntime->PutArrayElementReentrant( ExportValuesArray, 0, pRuntime->NewString(pFormControl->GetExportValue().AsStringView())); } @@ -1463,10 +1463,10 @@ } if (delay_) { - AddDelay_Bool(FP_HIDDEN, pRuntime->ToBoolean(vp)); + AddDelay_Bool(FP_HIDDEN, pRuntime->ToBooleanReentrant(vp)); } else { SetHidden(form_fill_env_.Get(), field_name_, form_control_index_, - pRuntime->ToBoolean(vp)); + pRuntime->ToBooleanReentrant(vp)); } return CJS_Result::Success(); } @@ -1544,10 +1544,10 @@ } if (delay_) { - AddDelay_Int(FP_LINEWIDTH, pRuntime->ToInt32(vp)); + AddDelay_Int(FP_LINEWIDTH, pRuntime->ToInt32Reentrant(vp)); } else { SetLineWidth(form_fill_env_.Get(), field_name_, form_control_index_, - pRuntime->ToInt32(vp)); + pRuntime->ToInt32Reentrant(vp)); } return CJS_Result::Success(); } @@ -1652,7 +1652,7 @@ return CJS_Result::Failure(JSMessage::kBadObjectError); } - pRuntime->PutArrayElement( + pRuntime->PutArrayElementReentrant( PageArray, i, pRuntime->NewNumber(pWidget->GetPageView()->GetPageIndex())); ++i; @@ -1724,7 +1724,7 @@ if (CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormField->GetControl(i))) { uint32_t dwFlags = pWidget->GetFlags(); - if (pRuntime->ToBoolean(vp)) { + if (pRuntime->ToBooleanReentrant(vp)) { dwFlags |= pdfium::annotation_flags::kPrint; } else { dwFlags &= ~pdfium::annotation_flags::kPrint; @@ -1752,7 +1752,7 @@ pFormField->GetControl(form_control_index_)) { if (CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl)) { uint32_t dwFlags = pWidget->GetFlags(); - if (pRuntime->ToBoolean(vp)) { + if (pRuntime->ToBooleanReentrant(vp)) { dwFlags |= pdfium::annotation_flags::kPrint; } else { dwFlags &= ~pdfium::annotation_flags::kPrint; @@ -1817,7 +1817,7 @@ return CJS_Result::Failure(JSMessage::kReadOnlyError); } - const bool bReadOnly = pRuntime->ToBoolean(vp); + const bool bReadOnly = pRuntime->ToBooleanReentrant(vp); const uint32_t dwFlags = pFormField->GetFieldFlags(); const uint32_t dwNewFlags = bReadOnly ? (dwFlags | pdfium::form_flags::kReadOnly) @@ -1843,13 +1843,13 @@ CFX_FloatRect crRect = pWidget->GetRect(); v8::Local<v8::Array> rcArray = pRuntime->NewArray(); - pRuntime->PutArrayElement( + pRuntime->PutArrayElementReentrant( rcArray, 0, pRuntime->NewNumber(static_cast<int32_t>(crRect.left))); - pRuntime->PutArrayElement( + pRuntime->PutArrayElementReentrant( rcArray, 1, pRuntime->NewNumber(static_cast<int32_t>(crRect.top))); - pRuntime->PutArrayElement( + pRuntime->PutArrayElementReentrant( rcArray, 2, pRuntime->NewNumber(static_cast<int32_t>(crRect.right))); - pRuntime->PutArrayElement( + pRuntime->PutArrayElementReentrant( rcArray, 3, pRuntime->NewNumber(static_cast<int32_t>(crRect.bottom))); return CJS_Result::Success(rcArray); @@ -1863,19 +1863,19 @@ return CJS_Result::Failure(JSMessage::kValueError); } - v8::Local<v8::Array> rcArray = pRuntime->ToArray(vp); + v8::Local<v8::Array> rcArray = pRuntime->ToArrayReentrant(vp); if (pRuntime->GetArrayLength(rcArray) < 4) { return CJS_Result::Failure(JSMessage::kValueError); } - float f0 = static_cast<float>( - pRuntime->ToInt32(pRuntime->GetArrayElement(rcArray, 0))); - float f1 = static_cast<float>( - pRuntime->ToInt32(pRuntime->GetArrayElement(rcArray, 1))); - float f2 = static_cast<float>( - pRuntime->ToInt32(pRuntime->GetArrayElement(rcArray, 2))); - float f3 = static_cast<float>( - pRuntime->ToInt32(pRuntime->GetArrayElement(rcArray, 3))); + float f0 = static_cast<float>(pRuntime->ToInt32Reentrant( + pRuntime->GetArrayElementReentrant(rcArray, 0))); + float f1 = static_cast<float>(pRuntime->ToInt32Reentrant( + pRuntime->GetArrayElementReentrant(rcArray, 1))); + float f2 = static_cast<float>(pRuntime->ToInt32Reentrant( + pRuntime->GetArrayElementReentrant(rcArray, 2))); + float f3 = static_cast<float>(pRuntime->ToInt32Reentrant( + pRuntime->GetArrayElementReentrant(rcArray, 3))); CFX_FloatRect crRect(f0, f1, f2, f3); if (delay_) { @@ -2156,7 +2156,7 @@ if (!can_set_) { return CJS_Result::Failure(JSMessage::kReadOnlyError); } - if (pRuntime->ToByteString(vp).IsEmpty()) { + if (pRuntime->ToByteStringReentrant(vp).IsEmpty()) { return CJS_Result::Failure(JSMessage::kValueError); } return CJS_Result::Success(); @@ -2268,11 +2268,11 @@ index = pFormField->GetSelectedIndex(i); ElementValue = pRuntime->NewString( pFormField->GetOptionValue(index).AsStringView()); - if (pRuntime->ToWideString(ElementValue).IsEmpty()) { + if (pRuntime->ToWideStringReentrant(ElementValue).IsEmpty()) { ElementValue = pRuntime->NewString( pFormField->GetOptionLabel(index).AsStringView()); } - pRuntime->PutArrayElement(ValueArray, i, ElementValue); + pRuntime->PutArrayElementReentrant(ValueArray, i, ElementValue); } ret = ValueArray; } else { @@ -2312,13 +2312,13 @@ std::vector<WideString> strArray; if (fxv8::IsArray(vp)) { - v8::Local<v8::Array> ValueArray = pRuntime->ToArray(vp); + v8::Local<v8::Array> ValueArray = pRuntime->ToArrayReentrant(vp); for (size_t i = 0; i < pRuntime->GetArrayLength(ValueArray); i++) { - strArray.push_back( - pRuntime->ToWideString(pRuntime->GetArrayElement(ValueArray, i))); + strArray.push_back(pRuntime->ToWideStringReentrant( + pRuntime->GetArrayElementReentrant(ValueArray, i))); } } else { - strArray.push_back(pRuntime->ToWideString(vp)); + strArray.push_back(pRuntime->ToWideStringReentrant(vp)); } if (delay_) { @@ -2398,7 +2398,7 @@ pdfium::span<v8::Local<v8::Value>> params) { int nface = 0; if (params.size() >= 1) { - nface = pRuntime->ToInt32(params[0]); + nface = pRuntime->ToInt32Reentrant(params[0]); } CPDF_FormField* pFormField = GetFirstFormField(); @@ -2433,7 +2433,7 @@ CJS_Result CJS_Field::buttonGetIcon(CJS_Runtime* pRuntime, pdfium::span<v8::Local<v8::Value>> params) { if (params.size() >= 1) { - int nFace = pRuntime->ToInt32(params[0]); + int nFace = pRuntime->ToInt32Reentrant(params[0]); if (nFace < 0 || nFace > 2) { return CJS_Result::Failure(JSMessage::kValueError); } @@ -2493,10 +2493,10 @@ return CJS_Result::Failure(JSMessage::kReadOnlyError); } - int nWidget = pRuntime->ToInt32(params[0]); + int nWidget = pRuntime->ToInt32Reentrant(params[0]); bool bCheckit = true; if (nSize >= 2) { - bCheckit = pRuntime->ToBoolean(params[1]); + bCheckit = pRuntime->ToBooleanReentrant(params[1]); } CPDF_FormField* pFormField = GetFirstFormField(); @@ -2540,7 +2540,7 @@ return CJS_Result::Failure(JSMessage::kBadObjectError); } - int nWidget = pRuntime->ToInt32(params[0]); + int nWidget = pRuntime->ToInt32Reentrant(params[0]); if (nWidget < 0 || nWidget >= pFormField->CountControls()) { return CJS_Result::Failure(JSMessage::kValueError); } @@ -2582,10 +2582,10 @@ auto* pJSField = static_cast<CJS_Field*>( CFXJS_Engine::GetBinding(pRuntime->GetIsolate(), pObj)); pJSField->AttachField(js_doc_.Get(), *pStr); - pRuntime->PutArrayElement(FormFieldArray, j++, - pJSField - ? v8::Local<v8::Value>(pJSField->ToV8Object()) - : v8::Local<v8::Value>()); + pRuntime->PutArrayElementReentrant( + FormFieldArray, j++, + pJSField ? v8::Local<v8::Value>(pJSField->ToV8Object()) + : v8::Local<v8::Value>()); } return CJS_Result::Success(FormFieldArray); } @@ -2595,12 +2595,12 @@ const size_t nSize = params.size(); int nIdx = -1; if (nSize >= 1) { - nIdx = pRuntime->ToInt32(params[0]); + nIdx = pRuntime->ToInt32Reentrant(params[0]); } bool bExport = true; if (nSize >= 2) { - bExport = pRuntime->ToBoolean(params[1]); + bExport = pRuntime->ToBooleanReentrant(params[1]); } CPDF_FormField* pFormField = GetFirstFormField(); @@ -2642,7 +2642,7 @@ pdfium::span<v8::Local<v8::Value>> params) { int nIndex = -1; if (params.size() >= 1) { - nIndex = pRuntime->ToInt32(params[0]); + nIndex = pRuntime->ToInt32Reentrant(params[0]); } CPDF_FormField* pFormField = GetFirstFormField(); @@ -2664,7 +2664,7 @@ pdfium::span<v8::Local<v8::Value>> params) { int nIndex = -1; if (params.size() >= 1) { - nIndex = pRuntime->ToInt32(params[0]); + nIndex = pRuntime->ToInt32Reentrant(params[0]); } CPDF_FormField* pFormField = GetFirstFormField();
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp index 382522a..7985056 100644 --- a/fxjs/cjs_global.cpp +++ b/fxjs/cjs_global.cpp
@@ -233,22 +233,23 @@ v8::Local<v8::Value> vp) { if (vp->IsNumber()) { return SetGlobalVariables(propname, CFX_Value::DataType::kNumber, - pRuntime->ToDouble(vp), false, ByteString(), - v8::Local<v8::Object>(), false); + pRuntime->ToDoubleReentrant(vp), false, + ByteString(), v8::Local<v8::Object>(), false); } if (vp->IsBoolean()) { return SetGlobalVariables(propname, CFX_Value::DataType::kBoolean, 0, - pRuntime->ToBoolean(vp), ByteString(), + pRuntime->ToBooleanReentrant(vp), ByteString(), v8::Local<v8::Object>(), false); } if (vp->IsString()) { return SetGlobalVariables(propname, CFX_Value::DataType::kString, 0, false, - pRuntime->ToByteString(vp), + pRuntime->ToByteStringReentrant(vp), v8::Local<v8::Object>(), false); } if (vp->IsObject()) { return SetGlobalVariables(propname, CFX_Value::DataType::kObject, 0, false, - ByteString(), pRuntime->ToObject(vp), false); + ByteString(), pRuntime->ToObjectReentrant(vp), + false); } if (vp->IsNull()) { return SetGlobalVariables(propname, CFX_Value::DataType::kNull, 0, false, @@ -271,7 +272,7 @@ continue; } v8::Local<v8::Name> name = pRuntime->NewString(it.first.AsStringView()); - pRuntime->PutArrayElement(result, idx, name); + pRuntime->PutArrayElementReentrant(result, idx, name); ++idx; } info.GetReturnValue().Set(result); @@ -284,12 +285,12 @@ return CJS_Result::Failure(JSMessage::kParamError); } - auto it = map_global_.find(pRuntime->ToByteString(params[0])); + auto it = map_global_.find(pRuntime->ToByteStringReentrant(params[0])); if (it == map_global_.end() || it->second->bDeleted) { return CJS_Result::Failure(JSMessage::kGlobalNotFoundError); } - it->second->bPersistent = pRuntime->ToBoolean(params[1]); + it->second->bPersistent = pRuntime->ToBooleanReentrant(params[1]); return CJS_Result::Success(); } @@ -306,15 +307,15 @@ SetGlobalVariables(pData->data.sKey, CFX_Value::DataType::kNumber, pData->data.dData, false, ByteString(), v8::Local<v8::Object>(), pData->bPersistent); - pRuntime->PutObjectProperty(ToV8Object(), - pData->data.sKey.AsStringView(), - pRuntime->NewNumber(pData->data.dData)); + pRuntime->PutObjectPropertyReentrant( + ToV8Object(), pData->data.sKey.AsStringView(), + pRuntime->NewNumber(pData->data.dData)); break; case CFX_Value::DataType::kBoolean: SetGlobalVariables(pData->data.sKey, CFX_Value::DataType::kBoolean, 0, pData->data.bData == 1, ByteString(), v8::Local<v8::Object>(), pData->bPersistent); - pRuntime->PutObjectProperty( + pRuntime->PutObjectPropertyReentrant( ToV8Object(), pData->data.sKey.AsStringView(), pRuntime->NewBoolean(pData->data.bData == 1)); break; @@ -322,7 +323,7 @@ SetGlobalVariables(pData->data.sKey, CFX_Value::DataType::kString, 0, false, pData->data.sData, v8::Local<v8::Object>(), pData->bPersistent); - pRuntime->PutObjectProperty( + pRuntime->PutObjectPropertyReentrant( ToV8Object(), pData->data.sKey.AsStringView(), pRuntime->NewString(pData->data.sData.AsStringView())); break; @@ -332,15 +333,15 @@ PutObjectProperty(pObj, &pData->data); SetGlobalVariables(pData->data.sKey, CFX_Value::DataType::kObject, 0, false, ByteString(), pObj, pData->bPersistent); - pRuntime->PutObjectProperty(ToV8Object(), - pData->data.sKey.AsStringView(), pObj); + pRuntime->PutObjectPropertyReentrant( + ToV8Object(), pData->data.sKey.AsStringView(), pObj); } } break; case CFX_Value::DataType::kNull: SetGlobalVariables(pData->data.sKey, CFX_Value::DataType::kNull, 0, false, ByteString(), v8::Local<v8::Object>(), pData->bPersistent); - pRuntime->PutObjectProperty( + pRuntime->PutObjectPropertyReentrant( ToV8Object(), pData->data.sKey.AsStringView(), pRuntime->NewNull()); break; } @@ -392,16 +393,17 @@ CJS_Runtime* pRuntime, v8::Local<v8::Object> pObj) { std::vector<std::unique_ptr<CFX_KeyValue>> array; - std::vector<WideString> pKeyList = pRuntime->GetObjectPropertyNames(pObj); + std::vector<WideString> pKeyList = + pRuntime->GetObjectPropertyNamesReentrant(pObj); for (const auto& ws : pKeyList) { ByteString sKey = ws.ToUTF8(); v8::Local<v8::Value> v = - pRuntime->GetObjectProperty(pObj, sKey.AsStringView()); + pRuntime->GetObjectPropertyReentrant(pObj, sKey.AsStringView()); if (v->IsNumber()) { auto pObjElement = std::make_unique<CFX_KeyValue>(); pObjElement->nType = CFX_Value::DataType::kNumber; pObjElement->sKey = sKey; - pObjElement->dData = pRuntime->ToDouble(v); + pObjElement->dData = pRuntime->ToDoubleReentrant(v); array.push_back(std::move(pObjElement)); continue; } @@ -409,12 +411,12 @@ auto pObjElement = std::make_unique<CFX_KeyValue>(); pObjElement->nType = CFX_Value::DataType::kBoolean; pObjElement->sKey = sKey; - pObjElement->dData = pRuntime->ToBoolean(v); + pObjElement->dData = pRuntime->ToBooleanReentrant(v); array.push_back(std::move(pObjElement)); continue; } if (v->IsString()) { - ByteString sValue = pRuntime->ToByteString(v); + ByteString sValue = pRuntime->ToByteStringReentrant(v); auto pObjElement = std::make_unique<CFX_KeyValue>(); pObjElement->nType = CFX_Value::DataType::kString; pObjElement->sKey = sKey; @@ -426,7 +428,8 @@ auto pObjElement = std::make_unique<CFX_KeyValue>(); pObjElement->nType = CFX_Value::DataType::kObject; pObjElement->sKey = sKey; - pObjElement->objData = ObjectToArray(pRuntime, pRuntime->ToObject(v)); + pObjElement->objData = + ObjectToArray(pRuntime, pRuntime->ToObjectReentrant(v)); array.push_back(std::move(pObjElement)); continue; } @@ -451,15 +454,17 @@ CFX_KeyValue* pObjData = pData->objData.at(i).get(); switch (pObjData->nType) { case CFX_Value::DataType::kNumber: - pRuntime->PutObjectProperty(pObj, pObjData->sKey.AsStringView(), - pRuntime->NewNumber(pObjData->dData)); + pRuntime->PutObjectPropertyReentrant( + pObj, pObjData->sKey.AsStringView(), + pRuntime->NewNumber(pObjData->dData)); break; case CFX_Value::DataType::kBoolean: - pRuntime->PutObjectProperty(pObj, pObjData->sKey.AsStringView(), - pRuntime->NewBoolean(pObjData->bData == 1)); + pRuntime->PutObjectPropertyReentrant( + pObj, pObjData->sKey.AsStringView(), + pRuntime->NewBoolean(pObjData->bData == 1)); break; case CFX_Value::DataType::kString: - pRuntime->PutObjectProperty( + pRuntime->PutObjectPropertyReentrant( pObj, pObjData->sKey.AsStringView(), pRuntime->NewString(pObjData->sData.AsStringView())); break; @@ -467,13 +472,13 @@ v8::Local<v8::Object> pNewObj = pRuntime->NewObject(); if (!pNewObj.IsEmpty()) { PutObjectProperty(pNewObj, pObjData); - pRuntime->PutObjectProperty(pObj, pObjData->sKey.AsStringView(), - pNewObj); + pRuntime->PutObjectPropertyReentrant( + pObj, pObjData->sKey.AsStringView(), pNewObj); } } break; case CFX_Value::DataType::kNull: - pRuntime->PutObjectProperty(pObj, pObjData->sKey.AsStringView(), - pRuntime->NewNull()); + pRuntime->PutObjectPropertyReentrant( + pObj, pObjData->sKey.AsStringView(), pRuntime->NewNull()); break; } }
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index e6f92f1..29349a8 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp
@@ -331,11 +331,11 @@ v8::Local<v8::Value> val) { DCHECK(!val.IsEmpty()); if (val->IsArray()) { - return pRuntime->ToArray(val); + return pRuntime->ToArrayReentrant(val); } DCHECK(val->IsString()); - ByteString bsVal = pRuntime->ToByteString(val); + ByteString bsVal = pRuntime->ToByteStringReentrant(val); const char* p = bsVal.c_str(); int nIndex = 0; @@ -345,13 +345,13 @@ while (*p) { const char* pTemp = strchr(p, ','); if (!pTemp) { - pRuntime->PutArrayElement( + pRuntime->PutArrayElementReentrant( StrArray, nIndex, pRuntime->NewString(StrTrim(ByteString(p)).AsStringView())); break; } - pRuntime->PutArrayElement( + pRuntime->PutArrayElementReentrant( StrArray, nIndex, pRuntime->NewString( StrTrim(ByteString(p, pTemp - p)).AsStringView())); @@ -630,12 +630,12 @@ return CJS_Result::Success(); } - int iDec = abs(pRuntime->ToInt32(params[0])); - int iSepStyle = ValidStyleOrZero(pRuntime->ToInt32(params[1])); - int iNegStyle = ValidStyleOrZero(pRuntime->ToInt32(params[2])); + int iDec = abs(pRuntime->ToInt32Reentrant(params[0])); + int iSepStyle = ValidStyleOrZero(pRuntime->ToInt32Reentrant(params[1])); + int iNegStyle = ValidStyleOrZero(pRuntime->ToInt32Reentrant(params[2])); // params[3] is iCurrStyle, it's not used. - WideString wstrCurrency = pRuntime->ToWideString(params[4]); - bool bCurrencyPrepend = pRuntime->ToBoolean(params[5]); + WideString wstrCurrency = pRuntime->ToWideStringReentrant(params[4]); + bool bCurrencyPrepend = pRuntime->ToBooleanReentrant(params[5]); // Processing decimal places NormalizeDecimalMark(&strValue); @@ -695,10 +695,11 @@ if (iNegStyle == 1 || iNegStyle == 3) { if (CJS_Field* fTarget = pEventContext->TargetField()) { v8::Local<v8::Array> arColor = pRuntime->NewArray(); - pRuntime->PutArrayElement(arColor, 0, pRuntime->NewString("RGB")); - pRuntime->PutArrayElement(arColor, 1, pRuntime->NewNumber(1)); - pRuntime->PutArrayElement(arColor, 2, pRuntime->NewNumber(0)); - pRuntime->PutArrayElement(arColor, 3, pRuntime->NewNumber(0)); + pRuntime->PutArrayElementReentrant(arColor, 0, + pRuntime->NewString("RGB")); + pRuntime->PutArrayElementReentrant(arColor, 1, pRuntime->NewNumber(1)); + pRuntime->PutArrayElementReentrant(arColor, 2, pRuntime->NewNumber(0)); + pRuntime->PutArrayElementReentrant(arColor, 3, pRuntime->NewNumber(0)); fTarget->set_text_color(pRuntime, arColor); } } @@ -706,14 +707,15 @@ if (iNegStyle == 1 || iNegStyle == 3) { if (CJS_Field* fTarget = pEventContext->TargetField()) { v8::Local<v8::Array> arColor = pRuntime->NewArray(); - pRuntime->PutArrayElement(arColor, 0, pRuntime->NewString("RGB")); - pRuntime->PutArrayElement(arColor, 1, pRuntime->NewNumber(0)); - pRuntime->PutArrayElement(arColor, 2, pRuntime->NewNumber(0)); - pRuntime->PutArrayElement(arColor, 3, pRuntime->NewNumber(0)); + pRuntime->PutArrayElementReentrant(arColor, 0, + pRuntime->NewString("RGB")); + pRuntime->PutArrayElementReentrant(arColor, 1, pRuntime->NewNumber(0)); + pRuntime->PutArrayElementReentrant(arColor, 2, pRuntime->NewNumber(0)); + pRuntime->PutArrayElementReentrant(arColor, 3, pRuntime->NewNumber(0)); CJS_Result result = fTarget->get_text_color(pRuntime); CFX_Color crProp = CJS_Color::ConvertArrayToPWLColor( - pRuntime, pRuntime->ToArray(result.Return())); + pRuntime, pRuntime->ToArrayReentrant(result.Return())); CFX_Color crColor = CJS_Color::ConvertArrayToPWLColor(pRuntime, arColor); if (crColor != crProp) { @@ -777,7 +779,7 @@ } } - int iSepStyle = ValidStyleOrZero(pRuntime->ToInt32(params[1])); + int iSepStyle = ValidStyleOrZero(pRuntime->ToInt32Reentrant(params[1])); const wchar_t cSep = DecimalMarkForStyle(iSepStyle); bool bHasSep = wstrValue.Contains(cSep); @@ -835,10 +837,11 @@ // Acrobat will accept this. Anything larger causes it to throw an error. static constexpr int kMaxSepStyle = 49; - int iDec = pRuntime->ToInt32(params[0]); - int iSepStyle = pRuntime->ToInt32(params[1]); + int iDec = pRuntime->ToInt32Reentrant(params[0]); + int iSepStyle = pRuntime->ToInt32Reentrant(params[1]); // TODO(thestig): How do we handle negative raw |bPercentPrepend| values? - bool bPercentPrepend = params.size() > 2 && pRuntime->ToBoolean(params[2]); + bool bPercentPrepend = + params.size() > 2 && pRuntime->ToBooleanReentrant(params[2]); if (iDec < 0 || iSepStyle < 0 || iSepStyle > kMaxSepStyle) { return CJS_Result::Failure(JSMessage::kValueError); } @@ -939,7 +942,7 @@ return CJS_Result::Success(); } - WideString sFormat = pRuntime->ToWideString(params[0]); + WideString sFormat = pRuntime->ToWideStringReentrant(params[0]); double dDate; if (strValue.Contains(L"GMT")) { // e.g. "Tue Aug 11 14:24:16 GMT+08002009" @@ -1023,7 +1026,7 @@ } bool bWrongFormat = false; - WideString sFormat = pRuntime->ToWideString(params[0]); + WideString sFormat = pRuntime->ToWideStringReentrant(params[0]); double dRet = ParseDateUsingFormat(pRuntime->GetIsolate(), strValue, sFormat, &bWrongFormat); if (bWrongFormat || isnan(dRet)) { @@ -1042,8 +1045,8 @@ return CJS_Result::Failure(JSMessage::kParamError); } - int index = - WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kDateFormats)); + int index = WithinBoundsOrZero(pRuntime->ToInt32Reentrant(params[0]), + std::size(kDateFormats)); v8::LocalVector<v8::Value> newParams(pRuntime->GetIsolate()); newParams.push_back(pRuntime->NewString(kDateFormats[index])); return AFDate_FormatEx(pRuntime, newParams); @@ -1057,8 +1060,8 @@ return CJS_Result::Failure(JSMessage::kParamError); } - int index = - WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kDateFormats)); + int index = WithinBoundsOrZero(pRuntime->ToInt32Reentrant(params[0]), + std::size(kDateFormats)); v8::LocalVector<v8::Value> newParams(pRuntime->GetIsolate()); newParams.push_back(pRuntime->NewString(kDateFormats[index])); return AFDate_KeystrokeEx(pRuntime, newParams); @@ -1072,8 +1075,8 @@ return CJS_Result::Failure(JSMessage::kParamError); } - int index = - WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kTimeFormats)); + int index = WithinBoundsOrZero(pRuntime->ToInt32Reentrant(params[0]), + std::size(kTimeFormats)); v8::LocalVector<v8::Value> newParams(pRuntime->GetIsolate()); newParams.push_back(pRuntime->NewString(kTimeFormats[index])); return AFDate_FormatEx(pRuntime, newParams); @@ -1086,8 +1089,8 @@ return CJS_Result::Failure(JSMessage::kParamError); } - int index = - WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kTimeFormats)); + int index = WithinBoundsOrZero(pRuntime->ToInt32Reentrant(params[0]), + std::size(kTimeFormats)); v8::LocalVector<v8::Value> newParams(pRuntime->GetIsolate()); newParams.push_back(pRuntime->NewString(kTimeFormats[index])); return AFDate_KeystrokeEx(pRuntime, newParams); @@ -1120,7 +1123,7 @@ const WideString& wsSource = pEvent->Value(); WideString wsFormat; - switch (pRuntime->ToInt32(params[0])) { + switch (pRuntime->ToInt32Reentrant(params[0])) { case 0: wsFormat = WideString::FromASCII("99999"); break; @@ -1157,7 +1160,7 @@ } const WideString& valEvent = pEvent->Value(); - WideString wstrMask = pRuntime->ToWideString(params[0]); + WideString wstrMask = pRuntime->ToWideStringReentrant(params[0]); if (wstrMask.IsEmpty()) { return CJS_Result::Success(); } @@ -1247,7 +1250,7 @@ } const char* cFormat = ""; - switch (pRuntime->ToInt32(params[0])) { + switch (pRuntime->ToInt32Reentrant(params[0])) { case 0: cFormat = "99999"; break; @@ -1300,8 +1303,8 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString sValue = pRuntime->ToWideString(params[0]); - WideString sFormat = pRuntime->ToWideString(params[1]); + WideString sValue = pRuntime->ToWideStringReentrant(params[0]); + WideString sFormat = pRuntime->ToWideStringReentrant(params[1]); double dDate = ParseDateUsingFormat(pRuntime->GetIsolate(), sValue, sFormat, nullptr); if (isnan(dDate)) { @@ -1321,9 +1324,9 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString sFunction = pRuntime->ToWideString(params[0]); - double arg1 = pRuntime->ToDouble(params[1]); - double arg2 = pRuntime->ToDouble(params[2]); + WideString sFunction = pRuntime->ToWideStringReentrant(params[0]); + double arg1 = pRuntime->ToDoubleReentrant(params[1]); + double arg2 = pRuntime->ToDoubleReentrant(params[2]); if (isnan(arg1) || isnan(arg2)) { return CJS_Result::Failure(JSMessage::kValueError); } @@ -1347,7 +1350,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString ws = pRuntime->ToWideString(params[0]); + WideString ws = pRuntime->ToWideStringReentrant(params[0]); NormalizeDecimalMarkW(&ws); v8::Local<v8::Value> val = @@ -1371,7 +1374,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString sFunction = pRuntime->ToWideString(params[0]); + WideString sFunction = pRuntime->ToWideStringReentrant(params[0]); v8::Local<v8::Array> FieldNameArray = AF_MakeArrayFromList(pRuntime, params[1]); @@ -1382,8 +1385,8 @@ double dValue = sFunction.EqualsASCII("PRD") ? 1.0 : 0.0; int nFieldsCount = 0; for (size_t i = 0; i < pRuntime->GetArrayLength(FieldNameArray); ++i) { - WideString wsFieldName = - pRuntime->ToWideString(pRuntime->GetArrayElement(FieldNameArray, i)); + WideString wsFieldName = pRuntime->ToWideStringReentrant( + pRuntime->GetArrayElementReentrant(FieldNameArray, i)); for (size_t j = 0; j < pForm->CountFields(wsFieldName); ++j) { CPDF_FormField* pFormField = pForm->GetField(j, wsFieldName); @@ -1452,7 +1455,8 @@ CJS_EventContext* context = pRuntime->GetCurrentEventContext(); if (context->HasValue()) { - context->Value() = pRuntime->ToWideString(pRuntime->NewNumber(dValue)); + context->Value() = + pRuntime->ToWideStringReentrant(pRuntime->NewNumber(dValue)); } return CJS_Result::Success(); @@ -1477,30 +1481,30 @@ } double dEventValue = atof(pEvent->Value().ToUTF8().c_str()); - bool bGreaterThan = pRuntime->ToBoolean(params[0]); - double dGreaterThan = pRuntime->ToDouble(params[1]); - bool bLessThan = pRuntime->ToBoolean(params[2]); - double dLessThan = pRuntime->ToDouble(params[3]); + bool bGreaterThan = pRuntime->ToBooleanReentrant(params[0]); + double dGreaterThan = pRuntime->ToDoubleReentrant(params[1]); + bool bLessThan = pRuntime->ToBooleanReentrant(params[2]); + double dLessThan = pRuntime->ToDoubleReentrant(params[3]); WideString swMsg; if (bGreaterThan && bLessThan) { if (dEventValue < dGreaterThan || dEventValue > dLessThan) { swMsg = WideString::Format( JSGetStringFromID(JSMessage::kRangeBetweenError).c_str(), - pRuntime->ToWideString(params[1]).c_str(), - pRuntime->ToWideString(params[3]).c_str()); + pRuntime->ToWideStringReentrant(params[1]).c_str(), + pRuntime->ToWideStringReentrant(params[3]).c_str()); } } else if (bGreaterThan) { if (dEventValue < dGreaterThan) { swMsg = WideString::Format( JSGetStringFromID(JSMessage::kRangeGreaterError).c_str(), - pRuntime->ToWideString(params[1]).c_str()); + pRuntime->ToWideStringReentrant(params[1]).c_str()); } } else if (bLessThan) { if (dEventValue > dLessThan) { swMsg = WideString::Format( JSGetStringFromID(JSMessage::kRangeLessError).c_str(), - pRuntime->ToWideString(params[3]).c_str()); + pRuntime->ToWideStringReentrant(params[3]).c_str()); } } @@ -1518,7 +1522,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString str = pRuntime->ToWideString(params[0]); + WideString str = pRuntime->ToWideStringReentrant(params[0]); if (IsDigitSeparatorOrDecimalMark(str.Front())) { // Front() safe when emtpy. str.InsertAtFront(L'0'); } @@ -1530,15 +1534,15 @@ if (FXSYS_IsDecimalDigit(wc)) { sPart += wc; } else if (sPart.GetLength() > 0) { - pRuntime->PutArrayElement(nums, nIndex, - pRuntime->NewString(sPart.AsStringView())); + pRuntime->PutArrayElementReentrant( + nums, nIndex, pRuntime->NewString(sPart.AsStringView())); sPart.clear(); nIndex++; } } if (sPart.GetLength() > 0) { - pRuntime->PutArrayElement(nums, nIndex, - pRuntime->NewString(sPart.AsStringView())); + pRuntime->PutArrayElementReentrant( + nums, nIndex, pRuntime->NewString(sPart.AsStringView())); } if (pRuntime->GetArrayLength(nums) > 0) { return CJS_Result::Success(nums);
diff --git a/fxjs/cjs_publicmethods_embeddertest.cpp b/fxjs/cjs_publicmethods_embeddertest.cpp index 94cef4b..1aa5c98 100644 --- a/fxjs/cjs_publicmethods_embeddertest.cpp +++ b/fxjs/cjs_publicmethods_embeddertest.cpp
@@ -198,8 +198,8 @@ runtime.GetCurrentEventContext()->SetValueForTest(&result); auto ary = runtime.NewArray(); - runtime.PutArrayElement(ary, 0, runtime.NewString("Calc1_A")); - runtime.PutArrayElement(ary, 1, runtime.NewString("Calc1_B")); + runtime.PutArrayElementReentrant(ary, 0, runtime.NewString("Calc1_A")); + runtime.PutArrayElementReentrant(ary, 1, runtime.NewString("Calc1_B")); v8::LocalVector<v8::Value> params(runtime.GetIsolate()); params.push_back(runtime.NewString("SUM"));
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp index 2c33ea7..2eb56b5 100644 --- a/fxjs/cjs_util.cpp +++ b/fxjs/cjs_util.cpp
@@ -110,7 +110,8 @@ // Use 'S' as a sentinel to ensure we always have some text before the first // format specifier. - WideString unsafe_fmt_string = L'S' + pRuntime->ToWideString(params[0]); + WideString unsafe_fmt_string = + L'S' + pRuntime->ToWideStringReentrant(params[0]); std::vector<WideString> unsafe_conversion_specifiers; { @@ -141,15 +142,16 @@ WideString segment; switch (ParseDataType(&fmt)) { case DataType::kInt: - segment = WideString::Format(fmt.c_str(), pRuntime->ToInt32(params[i])); + segment = WideString::Format(fmt.c_str(), + pRuntime->ToInt32Reentrant(params[i])); break; case DataType::kDouble: - segment = - WideString::Format(fmt.c_str(), pRuntime->ToDouble(params[i])); + segment = WideString::Format(fmt.c_str(), + pRuntime->ToDoubleReentrant(params[i])); break; case DataType::kString: - segment = WideString::Format(fmt.c_str(), - pRuntime->ToWideString(params[i]).c_str()); + segment = WideString::Format( + fmt.c_str(), pRuntime->ToWideStringReentrant(params[i]).c_str()); break; default: segment = WideString::Format(L"%ls", fmt.c_str()); @@ -176,11 +178,11 @@ } v8::Local<v8::Date> v8_date = params[1].As<v8::Date>(); - if (v8_date.IsEmpty() || isnan(pRuntime->ToDouble(v8_date))) { + if (v8_date.IsEmpty() || isnan(pRuntime->ToDoubleReentrant(v8_date))) { return CJS_Result::Failure(JSMessage::kSecondParamInvalidDateError); } - double date = FX_LocalTime(pRuntime->ToDouble(v8_date)); + double date = FX_LocalTime(pRuntime->ToDoubleReentrant(v8_date)); int year = FX_GetYearFromTime(date); int month = FX_GetMonthFromTime(date) + 1; // One-based. int day = FX_GetDayFromTime(date); @@ -190,7 +192,7 @@ if (params[0]->IsNumber()) { WideString swResult; - switch (pRuntime->ToInt32(params[0])) { + switch (pRuntime->ToInt32Reentrant(params[0])) { case 0: swResult = WideString::Format(L"D:%04d%02d%02d%02d%02d%02d", year, month, day, hour, min, sec); @@ -215,13 +217,13 @@ } // We don't support XFAPicture at the moment. - if (iSize > 2 && pRuntime->ToBoolean(params[2])) { + if (iSize > 2 && pRuntime->ToBooleanReentrant(params[2])) { return CJS_Result::Failure(JSMessage::kNotSupportedError); } // Convert PDF-style format specifiers to wcsftime specifiers. Remove any // pre-existing %-directives before inserting our own. - std::wstring cFormat = pRuntime->ToWideString(params[0]).c_str(); + std::wstring cFormat = pRuntime->ToWideStringReentrant(params[0]).c_str(); cFormat.erase(std::remove(cFormat.begin(), cFormat.end(), '%'), cFormat.end()); @@ -283,10 +285,10 @@ return CJS_Result::Failure(JSMessage::kParamError); } - return CJS_Result::Success( - pRuntime->NewString(StringPrintx(pRuntime->ToWideString(params[0]), - pRuntime->ToWideString(params[1])) - .AsStringView())); + return CJS_Result::Success(pRuntime->NewString( + StringPrintx(pRuntime->ToWideStringReentrant(params[0]), + pRuntime->ToWideStringReentrant(params[1])) + .AsStringView())); } // static @@ -385,8 +387,8 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString sFormat = pRuntime->ToWideString(params[0]); - WideString sDate = pRuntime->ToWideString(params[1]); + WideString sFormat = pRuntime->ToWideStringReentrant(params[0]); + WideString sDate = pRuntime->ToWideStringReentrant(params[1]); double dDate = FX_GetDateTime(); if (sDate.GetLength() > 0) { dDate = CJS_PublicMethods::ParseDateUsingFormat(pRuntime->GetIsolate(), @@ -405,7 +407,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - int arg = pRuntime->ToInt32(params[0]); + int arg = pRuntime->ToInt32Reentrant(params[0]); if (arg < 0 || arg > 255) { return CJS_Result::Failure(JSMessage::kValueError); }
diff --git a/fxjs/js_define.cpp b/fxjs/js_define.cpp index aaa3556..9fa717d 100644 --- a/fxjs/js_define.cpp +++ b/fxjs/js_define.cpp
@@ -81,12 +81,13 @@ } result[0] = v8::Local<v8::Value>(); // Make unknown. - v8::Local<v8::Object> pObj = pRuntime->ToObject(originals[0]); + v8::Local<v8::Object> pObj = pRuntime->ToObjectReentrant(originals[0]); va_list ap; va_start(ap, nKeywords); for (size_t i = 0; i < nKeywords; ++i) { const char* property = va_arg(ap, const char*); - v8::Local<v8::Value> v8Value = pRuntime->GetObjectProperty(pObj, property); + v8::Local<v8::Value> v8Value = + pRuntime->GetObjectPropertyReentrant(pObj, property); if (!v8Value->IsUndefined()) { result[i] = v8Value; }
diff --git a/fxjs/xfa/cjx_exclgroup.cpp b/fxjs/xfa/cjx_exclgroup.cpp index 3a36494..4aa5476 100644 --- a/fxjs/xfa/cjx_exclgroup.cpp +++ b/fxjs/xfa/cjx_exclgroup.cpp
@@ -41,8 +41,9 @@ return CJS_Result::Failure(JSMessage::kParamError); } - execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(), - XFA_Element::ExclGroup); + execSingleEventByName( + runtime->ToWideStringReentrant(params[0]).AsStringView(), + XFA_Element::ExclGroup); return CJS_Result::Success(); } @@ -111,7 +112,7 @@ pReturnNode = node->GetSelectedMember(); } else { pReturnNode = node->SetSelectedMember( - runtime->ToWideString(params[0]).AsStringView()); + runtime->ToWideStringReentrant(params[0]).AsStringView()); } if (!pReturnNode) { return CJS_Result::Success(runtime->NewNull());
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp index 6d2793b..d407e88 100644 --- a/fxjs/xfa/cjx_field.cpp +++ b/fxjs/xfa/cjx_field.cpp
@@ -59,7 +59,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString eventString = runtime->ToWideString(params[0]); + WideString eventString = runtime->ToWideStringReentrant(params[0]); XFA_EventError iRet = execSingleEventByName(eventString.AsStringView(), XFA_Element::Field); if (!eventString.EqualsASCII("validate")) { @@ -96,7 +96,8 @@ return CJS_Result::Success(); } - bool bValue = node->DeleteItem(runtime->ToInt32(params[0]), true, true); + bool bValue = + node->DeleteItem(runtime->ToInt32Reentrant(params[0]), true, true); return CJS_Result::Success(runtime->NewBoolean(bValue)); } @@ -106,7 +107,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - int32_t index = runtime->ToInt32(params[0]); + int32_t index = runtime->ToInt32Reentrant(params[0]); if (index < 0) { return CJS_Result::Success(runtime->NewNull()); } @@ -136,7 +137,7 @@ return CJS_Result::Success(); } - WideString value = runtime->ToWideString(params[0]); + WideString value = runtime->ToWideStringReentrant(params[0]); WideString boundValue = node->GetItemValue(value.AsStringView()); return CJS_Result::Success( runtime->NewString(boundValue.ToUTF8().AsStringView())); @@ -153,7 +154,7 @@ return CJS_Result::Success(); } - int32_t state = node->GetItemState(runtime->ToInt32(params[0])); + int32_t state = node->GetItemState(runtime->ToInt32Reentrant(params[0])); return CJS_Result::Success(runtime->NewBoolean(state != 0)); } @@ -178,7 +179,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - int32_t index = runtime->ToInt32(params[0]); + int32_t index = runtime->ToInt32Reentrant(params[0]); if (index < 0) { return CJS_Result::Success(runtime->NewNull()); } @@ -208,8 +209,8 @@ return CJS_Result::Success(); } - int32_t index = runtime->ToInt32(params[0]); - if (runtime->ToInt32(params[1]) != 0) { + int32_t index = runtime->ToInt32Reentrant(params[0]); + if (runtime->ToInt32Reentrant(params[1]) != 0) { node->SetItemState(index, true, true, true); return CJS_Result::Success(); } @@ -233,12 +234,12 @@ WideString label; if (params.size() >= 1) { - label = runtime->ToWideString(params[0]); + label = runtime->ToWideStringReentrant(params[0]); } WideString value; if (params.size() >= 2) { - value = runtime->ToWideString(params[1]); + value = runtime->ToWideStringReentrant(params[1]); } node->InsertItem(label, value, true);
diff --git a/fxjs/xfa/cjx_form.cpp b/fxjs/xfa/cjx_form.cpp index ac5ad7f..ac69a28 100644 --- a/fxjs/xfa/cjx_form.cpp +++ b/fxjs/xfa/cjx_form.cpp
@@ -93,7 +93,7 @@ } CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); - if (!pNotify || runtime->ToInt32(params[0]) != 0) { + if (!pNotify || runtime->ToInt32Reentrant(params[0]) != 0) { return CJS_Result::Success(); }
diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp index a654a64..7bb36a7 100644 --- a/fxjs/xfa/cjx_hostpseudomodel.cpp +++ b/fxjs/xfa/cjx_hostpseudomodel.cpp
@@ -284,7 +284,7 @@ return CJS_Result::Success(); } - pNotify->GetFFDoc()->GotoURL(runtime->ToWideString(params[0])); + pNotify->GetFFDoc()->GotoURL(runtime->ToWideStringReentrant(params[0])); return CJS_Result::Success(); } @@ -318,7 +318,8 @@ XFA_ResolveFlag::kSiblings}; std::optional<CFXJSE_Engine::ResolveResult> maybeResult = runtime->ResolveObjects( - pObject, runtime->ToWideString(params[0]).AsStringView(), kFlags); + pObject, runtime->ToWideStringReentrant(params[0]).AsStringView(), + kFlags); if (!maybeResult.has_value() || !maybeResult.value().objects.front()->IsNode()) { return CJS_Result::Success(); @@ -346,22 +347,22 @@ WideString question; if (params.size() >= 1) { - question = runtime->ToWideString(params[0]); + question = runtime->ToWideStringReentrant(params[0]); } WideString title; if (params.size() >= 2) { - title = runtime->ToWideString(params[1]); + title = runtime->ToWideStringReentrant(params[1]); } WideString defaultAnswer; if (params.size() >= 3) { - defaultAnswer = runtime->ToWideString(params[2]); + defaultAnswer = runtime->ToWideStringReentrant(params[2]); } bool mark = false; if (params.size() >= 4) { - mark = runtime->ToInt32(params[3]) != 0; + mark = runtime->ToInt32Reentrant(params[3]) != 0; } WideString answer = @@ -390,7 +391,7 @@ WideString expression; if (params.size() >= 1) { - expression = runtime->ToWideString(params[0]); + expression = runtime->ToWideStringReentrant(params[0]); } if (expression.IsEmpty()) { @@ -447,7 +448,7 @@ uint32_t dwType = 4; if (params.size() >= 1) { - dwType = runtime->ToInt32(params[0]); + dwType = runtime->ToInt32Reentrant(params[0]); } pNotify->GetAppProvider()->Beep(dwType); @@ -485,7 +486,8 @@ XFA_ResolveFlag::kSiblings}; std::optional<CFXJSE_Engine::ResolveResult> maybeResult = runtime->ResolveObjects( - pObject, runtime->ToWideString(params[0]).AsStringView(), kFlags); + pObject, runtime->ToWideStringReentrant(params[0]).AsStringView(), + kFlags); if (!maybeResult.has_value() || !maybeResult.value().objects.front()->IsNode()) { return CJS_Result::Success(); @@ -531,17 +533,17 @@ WideString message; if (params.size() >= 1) { - message = runtime->ToWideString(params[0]); + message = runtime->ToWideStringReentrant(params[0]); } WideString title; if (params.size() >= 2) { - title = runtime->ToWideString(params[1]); + title = runtime->ToWideStringReentrant(params[1]); } uint32_t messageType = static_cast<uint32_t>(AlertIcon::kDefault); if (params.size() >= 3) { - messageType = runtime->ToInt32(params[2]); + messageType = runtime->ToInt32Reentrant(params[2]); if (messageType > static_cast<uint32_t>(AlertIcon::kStatus)) { messageType = static_cast<uint32_t>(AlertIcon::kDefault); } @@ -549,7 +551,7 @@ uint32_t buttonType = static_cast<uint32_t>(AlertButton::kDefault); if (params.size() >= 4) { - buttonType = runtime->ToInt32(params[3]); + buttonType = runtime->ToInt32Reentrant(params[3]); if (buttonType > static_cast<uint32_t>(AlertButton::kYesNoCancel)) { buttonType = static_cast<uint32_t>(AlertButton::kDefault); } @@ -583,27 +585,27 @@ } Mask<XFA_PrintOpt> dwOptions; - if (runtime->ToBoolean(params[0])) { + if (runtime->ToBooleanReentrant(params[0])) { dwOptions |= XFA_PrintOpt::kShowDialog; } - if (runtime->ToBoolean(params[3])) { + if (runtime->ToBooleanReentrant(params[3])) { dwOptions |= XFA_PrintOpt::kCanCancel; } - if (runtime->ToBoolean(params[4])) { + if (runtime->ToBooleanReentrant(params[4])) { dwOptions |= XFA_PrintOpt::kShrinkPage; } - if (runtime->ToBoolean(params[5])) { + if (runtime->ToBooleanReentrant(params[5])) { dwOptions |= XFA_PrintOpt::kAsImage; } - if (runtime->ToBoolean(params[6])) { + if (runtime->ToBooleanReentrant(params[6])) { dwOptions |= XFA_PrintOpt::kReverseOrder; } - if (runtime->ToBoolean(params[7])) { + if (runtime->ToBooleanReentrant(params[7])) { dwOptions |= XFA_PrintOpt::kPrintAnnot; } - int32_t nStartPage = runtime->ToInt32(params[1]); - int32_t nEndPage = runtime->ToInt32(params[2]); + int32_t nStartPage = runtime->ToInt32Reentrant(params[1]); + int32_t nEndPage = runtime->ToInt32Reentrant(params[2]); pNotify->GetFFDoc()->Print(nStartPage, nEndPage, dwOptions); return CJS_Result::Success(); } @@ -632,12 +634,12 @@ WideString filePath; if (params.size() >= 1) { - filePath = runtime->ToWideString(params[0]); + filePath = runtime->ToWideStringReentrant(params[0]); } bool XDP = true; if (params.size() >= 2) { - XDP = runtime->ToBoolean(params[1]); + XDP = runtime->ToBooleanReentrant(params[1]); } pNotify->GetFFDoc()->ExportData(filePath, XDP);
diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp index e721773..87eb972 100644 --- a/fxjs/xfa/cjx_instancemanager.cpp +++ b/fxjs/xfa/cjx_instancemanager.cpp
@@ -146,8 +146,8 @@ return CJS_Result::Failure(JSMessage::kParamError); } - int32_t iFrom = runtime->ToInt32(params[0]); - int32_t iTo = runtime->ToInt32(params[1]); + int32_t iFrom = runtime->ToInt32Reentrant(params[0]); + int32_t iTo = runtime->ToInt32Reentrant(params[1]); MoveInstance(runtime->GetIsolate(), iTo, iFrom); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -181,7 +181,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - int32_t index = runtime->ToInt32(params[0]); + int32_t index = runtime->ToInt32Reentrant(params[0]); int32_t iCount = GetXFANode()->GetCount(); if (index < 0 || index >= iCount) { return CJS_Result::Failure(JSMessage::kInvalidInputError); @@ -226,7 +226,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - SetInstances(runtime->GetIsolate(), runtime->ToInt32(params[0])); + SetInstances(runtime->GetIsolate(), runtime->ToInt32Reentrant(params[0])); return CJS_Result::Success(); } @@ -244,7 +244,7 @@ bool fFlags = true; if (params.size() == 1) { - fFlags = runtime->ToBoolean(params[0]); + fFlags = runtime->ToBooleanReentrant(params[0]); } int32_t iCount = GetXFANode()->GetCount(); @@ -283,10 +283,10 @@ return CJS_Result::Failure(JSMessage::kParamError); } - int32_t index = runtime->ToInt32(params[0]); + int32_t index = runtime->ToInt32Reentrant(params[0]); bool bBind = false; if (params.size() == 2) { - bBind = runtime->ToBoolean(params[1]); + bBind = runtime->ToBooleanReentrant(params[1]); } int32_t iCount = GetXFANode()->GetCount();
diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp index 8649975..e0633af 100644 --- a/fxjs/xfa/cjx_layoutpseudomodel.cpp +++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp
@@ -98,12 +98,12 @@ WideString unit = WideString::FromASCII("pt"); if (params.size() >= 2) { - WideString tmp_unit = runtime->ToWideString(params[1]); + WideString tmp_unit = runtime->ToWideStringReentrant(params[1]); if (!tmp_unit.IsEmpty()) { unit = std::move(tmp_unit); } } - int32_t index = params.size() >= 3 ? runtime->ToInt32(params[2]) : 0; + int32_t index = params.size() >= 3 ? runtime->ToInt32Reentrant(params[2]) : 0; auto* pDocLayout = CXFA_LayoutProcessor::FromDocument(GetDocument()); CXFA_ContentLayoutItem* pLayoutItem = ToContentLayoutItem(pDocLayout->GetLayoutItem(pNode)); @@ -382,17 +382,17 @@ int32_t index = 0; if (params.size() >= 1) { - index = runtime->ToInt32(params[0]); + index = runtime->ToInt32Reentrant(params[0]); } WideString wsType; if (params.size() >= 2) { - wsType = runtime->ToWideString(params[1]); + wsType = runtime->ToWideStringReentrant(params[1]); } bool bOnPageArea = false; if (params.size() >= 3) { - bOnPageArea = runtime->ToBoolean(params[2]); + bOnPageArea = runtime->ToBooleanReentrant(params[2]); } CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
diff --git a/fxjs/xfa/cjx_list.cpp b/fxjs/xfa/cjx_list.cpp index a8548c5..018226b 100644 --- a/fxjs/xfa/cjx_list.cpp +++ b/fxjs/xfa/cjx_list.cpp
@@ -95,7 +95,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - int32_t index = runtime->ToInt32(params[0]); + int32_t index = runtime->ToInt32Reentrant(params[0]); size_t cast_index = static_cast<size_t>(index); if (index < 0 || cast_index >= GetXFAList()->GetLength()) { return CJS_Result::Failure(JSMessage::kInvalidInputError);
diff --git a/fxjs/xfa/cjx_model.cpp b/fxjs/xfa/cjx_model.cpp index 63ead4d..ce7318c 100644 --- a/fxjs/xfa/cjx_model.cpp +++ b/fxjs/xfa/cjx_model.cpp
@@ -44,15 +44,15 @@ WideString name; if (params.size() > 1) { - name = runtime->ToWideString(params[1]); + name = runtime->ToWideStringReentrant(params[1]); } WideString nameSpace; if (params.size() == 3) { - nameSpace = runtime->ToWideString(params[2]); + nameSpace = runtime->ToWideStringReentrant(params[2]); } - WideString tagName = runtime->ToWideString(params[0]); + WideString tagName = runtime->ToWideStringReentrant(params[0]); XFA_Element eType = XFA_GetElementByName(tagName.AsStringView()); CXFA_Node* pNewNode = GetXFANode()->CreateSamePacketNode(eType); if (!pNewNode) { @@ -81,7 +81,7 @@ WideString nameSpace; if (params.size() >= 1) { - nameSpace = runtime->ToWideString(params[0]); + nameSpace = runtime->ToWideStringReentrant(params[0]); } return CJS_Result::Success(
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp index 48b5ffc..5f05684 100644 --- a/fxjs/xfa/cjx_node.cpp +++ b/fxjs/xfa/cjx_node.cpp
@@ -139,7 +139,8 @@ return CJS_Result::Failure(JSMessage::kParamError); } - CXFA_Node* pCloneNode = GetXFANode()->Clone(runtime->ToBoolean(params[0])); + CXFA_Node* pCloneNode = + GetXFANode()->Clone(runtime->ToBooleanReentrant(params[0])); return CJS_Result::Success(runtime->GetOrCreateJSBindingFromMap(pCloneNode)); } @@ -149,7 +150,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString expression = runtime->ToWideString(params[0]); + WideString expression = runtime->ToWideStringReentrant(params[0]); return CJS_Result::Success(runtime->NewString( GetAttributeByString(expression.AsStringView()).ToUTF8().AsStringView())); } @@ -160,8 +161,9 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString expression = runtime->ToWideString(params[0]); - int32_t iValue = params.size() >= 2 ? runtime->ToInt32(params[1]) : 0; + WideString expression = runtime->ToWideStringReentrant(params[0]); + int32_t iValue = + params.size() >= 2 ? runtime->ToInt32Reentrant(params[1]) : 0; XFA_Element eElement = XFA_GetElementByName(expression.AsStringView()); if (eElement == XFA_Element::Unknown) { return CJS_Result::Success(runtime->NewNull()); @@ -182,7 +184,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString expression = runtime->ToWideString(params[0]); + WideString expression = runtime->ToWideStringReentrant(params[0]); std::optional<XFA_ATTRIBUTEINFO> attr = XFA_GetAttributeByName(expression.AsStringView()); if (attr.has_value() && HasAttribute(attr.value().attribute)) { @@ -194,8 +196,8 @@ return CJS_Result::Success(runtime->NewBoolean(false)); } - bool bParent = params.size() < 2 || runtime->ToBoolean(params[1]); - int32_t index = params.size() == 3 ? runtime->ToInt32(params[2]) : 0; + bool bParent = params.size() < 2 || runtime->ToBooleanReentrant(params[1]); + int32_t index = params.size() == 3 ? runtime->ToInt32Reentrant(params[2]) : 0; bool bHas = !!GetOrCreateProperty<CXFA_Node>(index, eType); if (!bHas && bParent && GetXFANode()->GetParent()) { // Also check on the parent. @@ -212,19 +214,19 @@ return CJS_Result::Failure(JSMessage::kParamError); } - ByteString expression = runtime->ToByteString(params[0]); + ByteString expression = runtime->ToByteStringReentrant(params[0]); if (expression.IsEmpty()) { return CJS_Result::Success(); } bool bIgnoreRoot = true; if (params.size() >= 2) { - bIgnoreRoot = runtime->ToBoolean(params[1]); + bIgnoreRoot = runtime->ToBooleanReentrant(params[1]); } bool bOverwrite = false; if (params.size() >= 3) { - bOverwrite = runtime->ToBoolean(params[2]); + bOverwrite = runtime->ToBooleanReentrant(params[2]); } auto stream = @@ -351,7 +353,7 @@ } if (params.size() == 1 && - !runtime->ToWideString(params[0]).EqualsASCII("pretty")) { + !runtime->ToWideStringReentrant(params[0]).EqualsASCII("pretty")) { return CJS_Result::Failure(JSMessage::kValueError); } @@ -395,8 +397,8 @@ // Note: yes, arglist is spec'd absolutely backwards from what any sane // person would do, namely value first, attribute second. - WideString attributeValue = runtime->ToWideString(params[0]); - WideString attribute = runtime->ToWideString(params[1]); + WideString attributeValue = runtime->ToWideStringReentrant(params[0]); + WideString attribute = runtime->ToWideStringReentrant(params[1]); // Pass them to our method, however, in the more usual manner. SetAttributeByString(attribute.AsStringView(), attributeValue);
diff --git a/fxjs/xfa/cjx_packet.cpp b/fxjs/xfa/cjx_packet.cpp index 8c2b4be..400c365 100644 --- a/fxjs/xfa/cjx_packet.cpp +++ b/fxjs/xfa/cjx_packet.cpp
@@ -44,7 +44,8 @@ WideString attributeValue; CFX_XMLElement* element = ToXMLElement(GetXFANode()->GetXMLMappingNode()); if (element) { - attributeValue = element->GetAttribute(runtime->ToWideString(params[0])); + attributeValue = + element->GetAttribute(runtime->ToWideStringReentrant(params[0])); } return CJS_Result::Success( @@ -59,8 +60,8 @@ CFX_XMLElement* element = ToXMLElement(GetXFANode()->GetXMLMappingNode()); if (element) { - element->SetAttribute(runtime->ToWideString(params[1]), - runtime->ToWideString(params[0])); + element->SetAttribute(runtime->ToWideStringReentrant(params[1]), + runtime->ToWideStringReentrant(params[0])); } return CJS_Result::Success(runtime->NewNull()); } @@ -74,7 +75,7 @@ CFX_XMLElement* pElement = ToXMLElement(GetXFANode()->GetXMLMappingNode()); if (pElement) { - pElement->RemoveAttribute(runtime->ToWideString(params[0])); + pElement->RemoveAttribute(runtime->ToWideStringReentrant(params[0])); } return CJS_Result::Success(runtime->NewNull());
diff --git a/fxjs/xfa/cjx_subform.cpp b/fxjs/xfa/cjx_subform.cpp index 3e87fd2..5db5ff2 100644 --- a/fxjs/xfa/cjx_subform.cpp +++ b/fxjs/xfa/cjx_subform.cpp
@@ -40,8 +40,9 @@ return CJS_Result::Failure(JSMessage::kParamError); } - execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(), - XFA_Element::Subform); + execSingleEventByName( + runtime->ToWideStringReentrant(params[0]).AsStringView(), + XFA_Element::Subform); return CJS_Result::Success(); }
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp index 2aed683..6d14cca 100644 --- a/fxjs/xfa/cjx_tree.cpp +++ b/fxjs/xfa/cjx_tree.cpp
@@ -41,7 +41,7 @@ return CJS_Result::Failure(JSMessage::kParamError); } - WideString wsExpression = runtime->ToWideString(params[0]); + WideString wsExpression = runtime->ToWideStringReentrant(params[0]); CXFA_Object* pRefNode = GetXFAObject(); if (pRefNode->GetElementType() == XFA_Element::Xfa) { pRefNode = runtime->GetThisObject(); @@ -92,9 +92,9 @@ XFA_ResolveFlag::kChildren, XFA_ResolveFlag::kAttributes, XFA_ResolveFlag::kProperties, XFA_ResolveFlag::kParent, XFA_ResolveFlag::kSiblings}; - return CJS_Result::Success(ResolveNodeList(runtime->GetIsolate(), - runtime->ToWideString(params[0]), - kFlags, ToNode(refNode))); + return CJS_Result::Success(ResolveNodeList( + runtime->GetIsolate(), runtime->ToWideStringReentrant(params[0]), kFlags, + ToNode(refNode))); } void CJX_Tree::all(v8::Isolate* pIsolate,
diff --git a/fxjs/xfa/cjx_treelist.cpp b/fxjs/xfa/cjx_treelist.cpp index bc26549..39497a9 100644 --- a/fxjs/xfa/cjx_treelist.cpp +++ b/fxjs/xfa/cjx_treelist.cpp
@@ -39,7 +39,7 @@ } CXFA_Node* pNode = GetXFATreeList()->NamedItem( - runtime->ToWideString(params[0]).AsStringView()); + runtime->ToWideStringReentrant(params[0]).AsStringView()); if (!pNode) { return CJS_Result::Success(); }