diff --git a/frameworks/js/napi/vibrator/src/vibrator_napi_utils.cpp b/frameworks/js/napi/vibrator/src/vibrator_napi_utils.cpp index ba21ffbb92a98acb3759b72c65a4c785d5854ecc..20fccaa60c329855bbdec750d53990323859b5f9 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 7380758256f85e9a4e94094b692252dec89d1254..62f5cc1e17bc5537fe1ae129eda5a5d93f9da800 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_);