diff options
author | thestig <thestig@chromium.org> | 2016-06-28 07:39:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-28 07:39:09 -0700 |
commit | 2d6dda170d84564f6ca5845ea934a886ac9bf746 (patch) | |
tree | f4d16014099db0e232799cc336439b5bd5f583f5 | |
parent | b21c6d0083e18077aa09b8cb1e4bb867dab2949e (diff) | |
download | pdfium-2d6dda170d84564f6ca5845ea934a886ac9bf746.tar.xz |
Implement IJS_Runtime::Destroy().
And call it from FPDF_DestroyLibrary(). Otherwise further attempts to
FPDF_InitLibraryWithConfig() can hit fail an assertion in
IJS_Runtime::Initialize().
BUG=604587
Review-Url: https://codereview.chromium.org/2103443004
-rw-r--r-- | fpdfsdk/fpdfview.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/javascript/JS_Runtime_Stub.cpp | 3 | ||||
-rw-r--r-- | fpdfsdk/javascript/cjs_runtime.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/javascript/ijs_runtime.h | 1 | ||||
-rw-r--r-- | testing/js_embedder_test.cpp | 1 |
5 files changed, 11 insertions, 1 deletions
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 38d704d27e..646fb46f72 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -291,6 +291,8 @@ DLLEXPORT void STDCALL FPDF_DestroyLibrary() { delete g_pCodecModule; g_pCodecModule = nullptr; + + IJS_Runtime::Destroy(); } #ifndef _WIN32 diff --git a/fpdfsdk/javascript/JS_Runtime_Stub.cpp b/fpdfsdk/javascript/JS_Runtime_Stub.cpp index 4930900337..39c191af70 100644 --- a/fpdfsdk/javascript/JS_Runtime_Stub.cpp +++ b/fpdfsdk/javascript/JS_Runtime_Stub.cpp @@ -161,6 +161,9 @@ class CJS_RuntimeStub final : public IJS_Runtime { void IJS_Runtime::Initialize(unsigned int slot, void* isolate) {} // static +void IJS_Runtime::Destroy() {} + +// static IJS_Runtime* IJS_Runtime::Create(CPDFDoc_Environment* pEnv) { return new CJS_RuntimeStub; } diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp index 2bcdc2293b..88530f7332 100644 --- a/fpdfsdk/javascript/cjs_runtime.cpp +++ b/fpdfsdk/javascript/cjs_runtime.cpp @@ -40,6 +40,11 @@ void IJS_Runtime::Initialize(unsigned int slot, void* isolate) { } // static +void IJS_Runtime::Destroy() { + FXJS_Release(); +} + +// static IJS_Runtime* IJS_Runtime::Create(CPDFDoc_Environment* pEnv) { return new CJS_Runtime(pEnv); } diff --git a/fpdfsdk/javascript/ijs_runtime.h b/fpdfsdk/javascript/ijs_runtime.h index 4083f86e87..b24a2dd916 100644 --- a/fpdfsdk/javascript/ijs_runtime.h +++ b/fpdfsdk/javascript/ijs_runtime.h @@ -22,6 +22,7 @@ class IJS_Context; class IJS_Runtime { public: static void Initialize(unsigned int slot, void* isolate); + static void Destroy(); static IJS_Runtime* Create(CPDFDoc_Environment* pEnv); virtual ~IJS_Runtime() {} diff --git a/testing/js_embedder_test.cpp b/testing/js_embedder_test.cpp index bdd1573a61..5927d89af5 100644 --- a/testing/js_embedder_test.cpp +++ b/testing/js_embedder_test.cpp @@ -28,7 +28,6 @@ void JSEmbedderTest::SetUp() { void JSEmbedderTest::TearDown() { FXJS_ReleaseRuntime(m_pIsolate, &m_pPersistentContext, &m_StaticObjects); m_pPersistentContext.Reset(); - FXJS_Release(); EmbedderTest::TearDown(); m_pIsolate->Dispose(); m_pIsolate = nullptr; |