protect stoi

This commit is contained in:
Richard Bainesly 2024-06-21 17:40:37 -04:00
parent e499411123
commit 1640958e37
2 changed files with 11 additions and 2 deletions

View file

@ -353,7 +353,12 @@ int main(int argc, char** argv) {
fullArgs += "f";
needRoll = true;
if (ARGS.size() >= 3)
rollRate = std::stoi(ARGS[2]);
try {
rollRate = std::stoi(ARGS[2]);
} catch (std::invalid_argument& e) {
log("invalid argument\n");
return 1;
}
} else if (ARGS[i] == "--batch") {
fullRequest = "--batch ";
} else if (ARGS[i] == "--instance" || ARGS[i] == "-i") {

View file

@ -1829,7 +1829,11 @@ int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
std::string val;
if (iss >> val) {
if (iss >> val) {
runWritingDebugLogThread(ACCEPTEDCONNECTION, std::stoi(val));
try {
runWritingDebugLogThread(ACCEPTEDCONNECTION, std::stoi(val));
} catch (std::invalid_argument& e) {
Debug::log(ERR, "Error in rollinglog request: {}", e.what());
}
} else {
runWritingDebugLogThread(ACCEPTEDCONNECTION);
}