diff --git a/services/common/src/time_provider.cpp b/services/common/src/time_provider.cpp index ec9b13bce005b1cb4549644ca58984d0b0daab87..e2fe0fdd3602a61bdea86da9091cf54c771a19d5 100644 --- a/services/common/src/time_provider.cpp +++ b/services/common/src/time_provider.cpp @@ -153,6 +153,10 @@ int32_t TimeProvider::GetCurrentDate() { time_t now = std::time(0); tm* local_time = localtime(&now); + if (local_time == nullptr) { + STANDBYSERVICE_LOGE("get local time failed"); + return 0; + } return local_time->tm_mday; } } // namespace DevStandbyMgr