diff --git a/interfaces/kits/js/src/mod_fs/class_tasksignal/task_signal_entity.cpp b/interfaces/kits/js/src/mod_fs/class_tasksignal/task_signal_entity.cpp index 99fee553d41278f26b031ceadba8172869f6e23e..75cd20a27393b351d4a6463201af95049a151317 100644 --- a/interfaces/kits/js/src/mod_fs/class_tasksignal/task_signal_entity.cpp +++ b/interfaces/kits/js/src/mod_fs/class_tasksignal/task_signal_entity.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -33,7 +33,7 @@ void TaskSignalEntity::OnCancel() } napi_handle_scope scope = nullptr; napi_status ret = napi_open_handle_scope(callbackContext->env_, &scope); - if (ret != napi_ok) { + if (ret != napi_ok || scope == nullptr) { return; } napi_env env = callbackContext->env_; diff --git a/interfaces/kits/js/src/mod_fs/properties/connectdfs.cpp b/interfaces/kits/js/src/mod_fs/properties/connectdfs.cpp index 380ba3502b93b42a5549b0640c7f8e4461953c41..c27c2c4361b08ac023c867c7d4ab07ae1ee87182 100644 --- a/interfaces/kits/js/src/mod_fs/properties/connectdfs.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/connectdfs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -196,8 +196,8 @@ ConnectDfsCB *CheckAndGetParameters(ConnectDfsCB *connectDfsCB, napi_handle_scop HILOGE("ConnectDfsCB, GetParam connectDfsCB is null"); return nullptr; } - napi_open_handle_scope(connectDfsCB->cbBase.cbInfo.env, scope); - if (scope == nullptr) { + napi_status ret = napi_open_handle_scope(connectDfsCB->cbBase.cbInfo.env, scope); + if (ret != napi_ok || scope == nullptr) { delete connectDfsCB; connectDfsCB = nullptr; return nullptr; diff --git a/interfaces/kits/js/src/mod_fs/properties/copy.cpp b/interfaces/kits/js/src/mod_fs/properties/copy.cpp index b800d5bc1453ac8869c954326c7f2176f3c2bad6..6ab78816b96a89e50e2d07bb5dca7f8658dbbc41 100644 --- a/interfaces/kits/js/src/mod_fs/properties/copy.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/copy.cpp @@ -183,7 +183,7 @@ void Copy::ReceiveComplete(std::shared_ptr entry) napi_handle_scope scope = nullptr; napi_env env = entry->callback->env; napi_status status = napi_open_handle_scope(env, &scope); - if (status != napi_ok) { + if (status != napi_ok || scope == nullptr) { HILOGE("Failed to open handle scope, status: %{public}d.", status); return; } diff --git a/interfaces/kits/js/src/mod_fs/properties/copy_listener/trans_listener.cpp b/interfaces/kits/js/src/mod_fs/properties/copy_listener/trans_listener.cpp index e83fb497ef657f3310533f8ccdff89829f5be7d5..4115a4e2478048b8997d6a8ac6fbd441ab70b31b 100644 --- a/interfaces/kits/js/src/mod_fs/properties/copy_listener/trans_listener.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/copy_listener/trans_listener.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -260,7 +260,7 @@ void TransListener::CallbackComplete(std::shared_ptr entry) napi_handle_scope scope = nullptr; napi_env env = entry->callback->env; napi_status status = napi_open_handle_scope(env, &scope); - if (status != napi_ok) { + if (status != napi_ok || scope == nullptr) { HILOGE("Failed to open handle scope, status: %{public}d.", status); return; }