From 34bb02cdd3fa98aa54f773de32eda80edcd6b16c Mon Sep 17 00:00:00 2001 From: Gaby Baghdadi Date: Wed, 30 Sep 2020 13:30:49 -0400 Subject: [PATCH] src: verify pointer before calling its method The destructor InstanceMethodCallBaton() calls m_javaObject->Unref() which aborts when m_javaObject is NULL. Affects at least `npm test` from `node-jdbc` npm, which aborts in test `testcreatetable`: (abort) [0x26C7C640] (__cxa_end_catch) [0x2E2CC414] (InstanceMethodCallBaton::~InstanceMethodCallBaton()+0x140) [0x2E2CD2A4] (Nan::AsyncWorker::Destroy()@AF61_58+0x28) [0x2E2CCE4C] (Nan::AsyncWorker::Destroy()+0x18) [0x2E2C9F12] (Nan::AsyncExecuteComplete(uv_work_s*)+0x4e) [0x27DB5430] ... --- src/methodCallBaton.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/methodCallBaton.cpp b/src/methodCallBaton.cpp index 61e16189..08119949 100644 --- a/src/methodCallBaton.cpp +++ b/src/methodCallBaton.cpp @@ -236,5 +236,8 @@ InstanceMethodCallBaton::InstanceMethodCallBaton( } InstanceMethodCallBaton::~InstanceMethodCallBaton() { - m_javaObject->Unref(); + if (m_javaObject) { + m_javaObject->Unref(); + m_javaObject = NULL; + } }