summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fsdk_filewriteadapter.cpp2
-rw-r--r--fpdfsdk/javascript/cjs_runtime.cpp21
2 files changed, 9 insertions, 14 deletions
diff --git a/fpdfsdk/fsdk_filewriteadapter.cpp b/fpdfsdk/fsdk_filewriteadapter.cpp
index ff527a6f2e..50394c3286 100644
--- a/fpdfsdk/fsdk_filewriteadapter.cpp
+++ b/fpdfsdk/fsdk_filewriteadapter.cpp
@@ -18,5 +18,5 @@ bool FSDK_FileWriteAdapter::WriteBlock(const void* data, size_t size) {
}
bool FSDK_FileWriteAdapter::WriteString(const CFX_ByteStringC& str) {
- return WriteBlock(str.c_str(), str.GetLength());
+ return WriteBlock(str.unterminated_c_str(), str.GetLength());
}
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index cb8f69f9da..515bdcb65f 100644
--- a/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -218,19 +218,16 @@ CFX_WideString ChangeObjName(const CFX_WideString& str) {
sRet.Replace(L"_", L".");
return sRet;
}
+
bool CJS_Runtime::GetValueByName(const CFX_ByteStringC& utf8Name,
CFXJSE_Value* pValue) {
- const char* name = utf8Name.c_str();
-
v8::Isolate::Scope isolate_scope(GetIsolate());
v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Context> context = NewLocalContext();
v8::Context::Scope context_scope(context);
-
- v8::Local<v8::Value> propvalue =
- context->Global()->Get(v8::String::NewFromUtf8(
- GetIsolate(), name, v8::String::kNormalString, utf8Name.GetLength()));
-
+ v8::Local<v8::Value> propvalue = context->Global()->Get(
+ v8::String::NewFromUtf8(GetIsolate(), utf8Name.unterminated_c_str(),
+ v8::String::kNormalString, utf8Name.GetLength()));
if (propvalue.IsEmpty()) {
pValue->SetUndefined();
return false;
@@ -238,24 +235,22 @@ bool CJS_Runtime::GetValueByName(const CFX_ByteStringC& utf8Name,
pValue->ForceSetValue(propvalue);
return true;
}
+
bool CJS_Runtime::SetValueByName(const CFX_ByteStringC& utf8Name,
CFXJSE_Value* pValue) {
if (utf8Name.IsEmpty() || !pValue)
return false;
- const char* name = utf8Name.c_str();
+
v8::Isolate* pIsolate = GetIsolate();
v8::Isolate::Scope isolate_scope(pIsolate);
v8::HandleScope handle_scope(pIsolate);
v8::Local<v8::Context> context = NewLocalContext();
v8::Context::Scope context_scope(context);
-
- // v8::Local<v8::Context> tmpCotext =
- // v8::Local<v8::Context>::New(GetIsolate(), m_context);
v8::Local<v8::Value> propvalue =
v8::Local<v8::Value>::New(GetIsolate(), pValue->DirectGetValue());
context->Global()->Set(
- v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString,
- utf8Name.GetLength()),
+ v8::String::NewFromUtf8(pIsolate, utf8Name.unterminated_c_str(),
+ v8::String::kNormalString, utf8Name.GetLength()),
propvalue);
return true;
}