diff --git a/services/native/src/work_scheduler_service.cpp b/services/native/src/work_scheduler_service.cpp index 97dda8fa4e2ac9f44642b91ada943821cd111d94..b59c99dcf08fcfd322d2c34132b40a232aacce8e 100644 --- a/services/native/src/work_scheduler_service.cpp +++ b/services/native/src/work_scheduler_service.cpp @@ -1112,7 +1112,11 @@ void WorkSchedulerService::DumpRunningWorks(const std::string &uidStr, const std return; } - int32_t uid = std::stoi(uidStr); + int32_t uid = std::atoi(uidStr.c_str()); + if (uid == 0) { + result.append("uidStr param error, uidStr:" + uidStr); + return; + } int32_t ret = ERR_OK; if (option == "p") { ret = workPolicyManager_->PauseRunningWorks(uid); @@ -1527,9 +1531,9 @@ void WorkSchedulerService::DumpLoadSaWorks(const std::string &saIdStr, const std result.append("param error."); return; } - int32_t saId = std::stoi(saIdStr); - int32_t uid = std::stoi(uidStr); - if (saId < 0 || uid < 0) { + int32_t saId = std::atoi(saIdStr.c_str()); + int32_t uid = std::atoi(uidStr.c_str()); + if (saId <= 0 || uid <= 0) { result.append("the parameter is invalid."); return; }