From afc0ddad55b2dc24cfa45faa1a0a4bfa4cc9e252 Mon Sep 17 00:00:00 2001 From: wuzhihuitmac Date: Sat, 9 Aug 2025 15:30:45 +0800 Subject: [PATCH] Modify security alerts Signed-off-by: wuzhihuitmac Change-Id: Ia96cba2320de254f63d65484babd7e4d6f611ff9 --- .../js/napi/vibrator/src/vibrator_napi_utils.cpp | 2 +- .../native/vibrator/src/vibrator_service_client.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frameworks/js/napi/vibrator/src/vibrator_napi_utils.cpp b/frameworks/js/napi/vibrator/src/vibrator_napi_utils.cpp index ba21ffb..20fccaa 100644 --- a/frameworks/js/napi/vibrator/src/vibrator_napi_utils.cpp +++ b/frameworks/js/napi/vibrator/src/vibrator_napi_utils.cpp @@ -212,7 +212,7 @@ bool GetStringValue(const napi_env &env, const napi_value &value, string &result return false; } bufLength = bufLength > STRING_LENGTH_MAX ? STRING_LENGTH_MAX : bufLength; - char str[STRING_LENGTH_MAX] = {0}; + char str[STRING_LENGTH_MAX + 1] = {0}; size_t strLen = 0; ret = napi_get_value_string_utf8(env, value, str, bufLength + 1, &strLen); if (ret != napi_ok) { diff --git a/frameworks/native/vibrator/src/vibrator_service_client.cpp b/frameworks/native/vibrator/src/vibrator_service_client.cpp index 7380758..62f5cc1 100644 --- a/frameworks/native/vibrator/src/vibrator_service_client.cpp +++ b/frameworks/native/vibrator/src/vibrator_service_client.cpp @@ -64,10 +64,13 @@ namespace { VibratorServiceClient::~VibratorServiceClient() { - if (miscdeviceProxy_ != nullptr && serviceDeathObserver_ != nullptr) { - auto remoteObject = miscdeviceProxy_->AsObject(); - if (remoteObject != nullptr) { - remoteObject->RemoveDeathRecipient(serviceDeathObserver_); + { + std::lock_guard clientLock(clientMutex_); + if (miscdeviceProxy_ != nullptr && serviceDeathObserver_ != nullptr) { + auto remoteObject = miscdeviceProxy_->AsObject(); + if (remoteObject != nullptr) { + remoteObject->RemoveDeathRecipient(serviceDeathObserver_); + } } } std::lock_guard decodeLock(decodeMutex_); -- Gitee