diff --git a/services/native/src/work_scheduler_service.cpp b/services/native/src/work_scheduler_service.cpp index 22766e7a2a36c2150bfbf875ff7935c61ba48371..46af9306e5ded672515abbbb213b6a3d5815717b 100644 --- a/services/native/src/work_scheduler_service.cpp +++ b/services/native/src/work_scheduler_service.cpp @@ -226,6 +226,10 @@ list> WorkSchedulerService::ReadPersistedWorks() if (!GetJsonFromFile(PERSISTED_FILE_PATH, root)) { return workInfos; } + if (root.empty() || !root.isObject()) { + WS_HILOGE("ReadPersistedWorks failed, root is empty or not an object"); + return workInfos; + } for (const auto &it : root.getMemberNames()) { Json::Value workJson = root[it]; shared_ptr workInfo = make_shared();