From 6fc66c529cb68f4eefacdbc0e9cb0edfee1d1249 Mon Sep 17 00:00:00 2001 From: hui1975 Date: Fri, 12 Aug 2022 17:20:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E5=9B=9E=E8=B0=83=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E4=B8=AD=E7=9A=84napi=E6=8E=A5=E5=8F=A3=E5=8C=85=E4=B8=8Ascope?= =?UTF-8?q?=E4=BD=9C=E7=94=A8=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hui1975 Change-Id: Id938cf1ddfcd0c84ca2c46172d7377a7ae5df5ef --- interfaces/plugin/src/sensor_napi_utils.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/interfaces/plugin/src/sensor_napi_utils.cpp b/interfaces/plugin/src/sensor_napi_utils.cpp index bbf2f46b..b352362b 100644 --- a/interfaces/plugin/src/sensor_napi_utils.cpp +++ b/interfaces/plugin/src/sensor_napi_utils.cpp @@ -532,6 +532,11 @@ void EmitUvEventLoop(sptr asyncCallbackInfo) * count of the smart pointer is guaranteed to be 1. */ asyncCallbackInfo->DecStrongRef(nullptr); + napi_handle_scope scope = nullptr; + napi_open_handle_scope(asyncCallbackInfo->env, &scope); + if (scope == nullptr) { + return; + } napi_env env = asyncCallbackInfo->env; napi_value callback = nullptr; CHKNRV(env, napi_get_reference_value(env, asyncCallbackInfo->callback[0], &callback), @@ -542,6 +547,7 @@ void EmitUvEventLoop(sptr asyncCallbackInfo) "Asynccallback Type invalid in uv work"); g_convertfuncList[asyncCallbackInfo->type](env, asyncCallbackInfo, result); CHKNRV(env, napi_call_function(env, nullptr, callback, 1, &result[1], &callResult), "napi_call_function"); + napi_close_handle_scope(asyncCallbackInfo->env, scope); asyncCallbackInfo->work = nullptr; freeWork(work); }); -- Gitee