diff --git a/interfaces/plugin/vibrator/src/vibrator_napi_utils.cpp b/interfaces/plugin/vibrator/src/vibrator_napi_utils.cpp index 749219902e8300214c7c5fcccd370c8fbb0d2f35..29ac5a7bf608525111b6b651f4a9a00c02d7aebb 100644 --- a/interfaces/plugin/vibrator/src/vibrator_napi_utils.cpp +++ b/interfaces/plugin/vibrator/src/vibrator_napi_utils.cpp @@ -99,7 +99,7 @@ bool GetStringValue(const napi_env &env, const napi_value &value, string &result NAPI_CALL_BASE(env, napi_get_value_string_utf8(env, value, nullptr, 0, &bufLength), false); char str[STRING_LENGTH_MAX] = {0}; size_t strLen = 0; - NAPI_CALL_BASE(env, napi_get_value_string_utf8(env, value, str, bufLength, &strLen), false); + NAPI_CALL_BASE(env, napi_get_value_string_utf8(env, value, str, bufLength + 1, &strLen), false); result = str; return true; } @@ -244,4 +244,4 @@ void EmitPromiseWork(sptr asyncCallbackInfo) } } } // namespace Sensors -} // namespace OHOS \ No newline at end of file +} // namespace OHOS