From 8ba0467e6fefa02ccd585d111942c63abea56d91 Mon Sep 17 00:00:00 2001 From: SUE Date: Thu, 24 Feb 2022 03:32:15 +0000 Subject: [PATCH] Signed-off-by:hellohyh001 --- frameworks/native/sensor/src/sensor_agent_proxy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/native/sensor/src/sensor_agent_proxy.cpp b/frameworks/native/sensor/src/sensor_agent_proxy.cpp index ce29e2f1..db6c8625 100755 --- a/frameworks/native/sensor/src/sensor_agent_proxy.cpp +++ b/frameworks/native/sensor/src/sensor_agent_proxy.cpp @@ -343,8 +343,8 @@ int32_t SensorAgentProxy::GetAllSensors(SensorInfo **sensorInfo, int32_t *count) HiLog::Error(LABEL, "%{public}s strcpy vendorName failed", __func__); return OHOS::Sensors::ERROR; } - const char *version = std::to_string(sensorList_[index].GetVersion()).c_str(); - ret = strcpy_s((*sensorInfo + index)->hardwareVersion, VERSION_MAX_LEN, version); + std::string version = std::to_string(sensorList_[index].GetVersion()); + ret = strcpy_s((*sensorInfo + index)->hardwareVersion, VERSION_MAX_LEN, version.c_str()); if (ret != EOK) { HiLog::Error(LABEL, "%{public}s strcpy hardwareVersion failed", __func__); return OHOS::Sensors::ERROR; -- Gitee