Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: fpdfsdk/src/javascript/JS_Runtime.cpp

Issue 1412103010: Segv when PDF-side JS object property getter invoked from XFA. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/src/javascript/JS_Define.h ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/javascript/JS_Runtime.cpp
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 8b0475b85110d3c09d9325b6e499685372f0b5d9..9c2c6c6fed47073cb23092b764301e3c6d6aefae 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -245,12 +245,18 @@ FX_BOOL CJS_Runtime::GetHValueByName(const CFX_ByteStringC& utf8Name,
v8::Locker lock(GetIsolate());
v8::Isolate::Scope isolate_scope(GetIsolate());
v8::HandleScope handle_scope(GetIsolate());
+ v8::Local<v8::Context> old_context = GetIsolate()->GetCurrentContext();
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(GetIsolate(), m_context);
v8::Context::Scope context_scope(context);
- // v8::Local<v8::Context> tmpCotext =
- // v8::Local<v8::Context>::New(GetIsolate(), m_context);
+ // Caution: We're about to hand to XFA an object that may well require
+ // |context| to obtain this CJS_Runtime, but XFA will invoke against
+ // its own |old_context|, which has no CJS_Runtime. Associate ourselves
+ // with it at this point.
jochen (gone - plz use gerrit) 2015/11/07 05:56:18 i don't understand this comment?
Tom Sepez 2015/11/09 22:15:05 Because the new XFA code and the old PDF code don'
+ // TODO(tsepez): redesign PDF-side objects to not rely on context.
jochen (gone - plz use gerrit) 2015/11/07 05:56:18 nor this
Tom Sepez 2015/11/09 22:15:05 Changed. Better?
+ FXJS_SetRuntimeForV8Context(old_context, this);
+
v8::Local<v8::Value> propvalue =
context->Global()->Get(v8::String::NewFromUtf8(
GetIsolate(), name, v8::String::kNormalString, utf8Name.GetLength()));
« no previous file with comments | « fpdfsdk/src/javascript/JS_Define.h ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698