diff --git a/services/include/sensor_manager.h b/services/include/sensor_manager.h index c77736407c83f2613d86a6d831eab2cd7f9d5405..c5e8d031f588d63960960dbc413ed69b7accc7a4 100644 --- a/services/include/sensor_manager.h +++ b/services/include/sensor_manager.h @@ -53,8 +53,8 @@ private: #ifdef HDF_DRIVERS_INTERFACE_SENSOR SensorHdiConnection &sensorHdiConnection_ = SensorHdiConnection::GetInstance(); std::thread dataThread_; - sptr sensorDataProcesser_; - sptr reportDataCallback_; + sptr sensorDataProcesser_ = nullptr; + sptr reportDataCallback_ = nullptr; #endif // HDF_DRIVERS_INTERFACE_SENSOR ClientInfo &clientInfo_ = ClientInfo::GetInstance(); std::unordered_map sensorMap_; diff --git a/services/src/sensor_data_processer.cpp b/services/src/sensor_data_processer.cpp index 8c1b010f234a0b736fa23226b75eb28171ef063a..47e83bb964657eea153ef446157ab4c72ebbe3c6 100644 --- a/services/src/sensor_data_processer.cpp +++ b/services/src/sensor_data_processer.cpp @@ -295,6 +295,10 @@ int32_t SensorDataProcesser::DataThread(sptr dataProcesser, CALL_LOG_ENTER; prctl(PR_SET_NAME, SENSOR_REPORT_THREAD_NAME.c_str()); do { + if (dataProcesser == nullptr || dataCallback == nullptr) { + SEN_HILOGE("dataProcesser or dataCallback is nullptr"); + return INVALID_POINTER; + } if (dataProcesser->ProcessEvents(dataCallback) == INVALID_POINTER) { SEN_HILOGE("Callback cannot be null"); return INVALID_POINTER;