diff --git a/frameworks/native/src/sensor_agent_proxy.cpp b/frameworks/native/src/sensor_agent_proxy.cpp index dfb11bc27ea87c65d5e184e255383add3718f3b7..a1cc1fbd55e21a299bf213fe2bb504e951b9df72 100644 --- a/frameworks/native/src/sensor_agent_proxy.cpp +++ b/frameworks/native/src/sensor_agent_proxy.cpp @@ -438,6 +438,10 @@ int32_t SensorAgentProxy::GetAllSensors(SensorInfo **sensorInfo, int32_t *count) CHKPR(sensorInfo, OHOS::Sensors::ERROR); CHKPR(count, OHOS::Sensors::ERROR); std::lock_guard listLock(sensorInfoMutex_); + if ((*sensorInfo) == nullptr) { + SEN_HILOGE("sensorInfo pointer is null"); + return ERROR; + } int32_t ret = ConvertSensorInfos(); if (ret != SUCCESS) { SEN_HILOGE("Convert sensor lists failed");