diff --git a/interfaces/kits/js/cloudfilesync/cloud_file_version_napi.cpp b/interfaces/kits/js/cloudfilesync/cloud_file_version_napi.cpp index 0912800e4b9d5b95516f33f38a0f955efa60651b..0116f35e51a9bd97347443699227bb9ad5665b9a 100644 --- a/interfaces/kits/js/cloudfilesync/cloud_file_version_napi.cpp +++ b/interfaces/kits/js/cloudfilesync/cloud_file_version_napi.cpp @@ -452,9 +452,13 @@ void VersionDownloadCallbackImpl::OnComplete(UvChangeMsg *msg) auto env = downloadcCallback->env_; auto ref = downloadcCallback->cbOnRef_; napi_handle_scope scope = nullptr; - napi_open_handle_scope(env, &scope); + napi_status status = napi_open_handle_scope(env, &scope); + if (status != napi_ok || scope == nullptr) { + LOGE("open handle scope failed, status: %{public}d", status); + return; + } napi_value jsCallback = nullptr; - napi_status status = napi_get_reference_value(env, ref, &jsCallback); + status = napi_get_reference_value(env, ref, &jsCallback); if (status != napi_ok) { LOGE("Create reference failed, status: %{public}d", status); napi_close_handle_scope(env, scope); diff --git a/interfaces/kits/js/cloudfilesync/cloud_sync_napi.cpp b/interfaces/kits/js/cloudfilesync/cloud_sync_napi.cpp index c92c1db48a145e50ee9eaf06579c5298a1a2c3de..aae5bd6b1796b12d1c5eaf32d709405ccd32d3dd 100644 --- a/interfaces/kits/js/cloudfilesync/cloud_sync_napi.cpp +++ b/interfaces/kits/js/cloudfilesync/cloud_sync_napi.cpp @@ -135,9 +135,13 @@ void CloudSyncCallbackImpl::OnComplete(UvChangeMsg *msg) auto env = cloudSyncCallback->env_; auto ref = cloudSyncCallback->cbOnRef_; napi_handle_scope scope = nullptr; - napi_open_handle_scope(env, &scope); + napi_status status = napi_open_handle_scope(env, &scope); + if (status != napi_ok || scope == nullptr) { + LOGE("open handle scope failed, status: %{public}d", status); + return; + } napi_value jsCallback = nullptr; - napi_status status = napi_get_reference_value(env, ref, &jsCallback); + status = napi_get_reference_value(env, ref, &jsCallback); if (status != napi_ok) { LOGE("Create reference failed, status: %{public}d", status); napi_close_handle_scope(env, scope);