aboutsummaryrefslogtreecommitdiffhomepage
path: root/hyprctl/main.cpp
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-02-18 23:31:43 +0000
committerVaxry <[email protected]>2024-02-18 23:31:43 +0000
commitc6b1d82c70290faf051b82a9d2968f52a08c242e (patch)
tree932a2ce6e2548fa4ea55b0b5b78dc921a6f0f086 /hyprctl/main.cpp
parent301b48b74087cc59753ffa144b215540e6f82831 (diff)
downloadHyprland-c6b1d82c70290faf051b82a9d2968f52a08c242e.tar.gz
Hyprland-c6b1d82c70290faf051b82a9d2968f52a08c242e.zip
hyprctl: more safety around stoull
Diffstat (limited to 'hyprctl/main.cpp')
-rw-r--r--hyprctl/main.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp
index b1d89a8a..6126c514 100644
--- a/hyprctl/main.cpp
+++ b/hyprctl/main.cpp
@@ -86,7 +86,9 @@ std::vector<SInstanceData> instances() {
data->id = el.path().string();
data->id = data->id.substr(data->id.find_last_of('/') + 1, data->id.find(".lock") - data->id.find_last_of('/') - 1);
- data->time = std::stoull(data->id.substr(data->id.find_first_of('_') + 1));
+ try {
+ data->time = std::stoull(data->id.substr(data->id.find_first_of('_') + 1));
+ } catch (std::exception& e) { data->time = 0; }
// read file
std::ifstream ifs(el.path().string());
@@ -94,7 +96,9 @@ std::vector<SInstanceData> instances() {
int i = 0;
for (std::string line; std::getline(ifs, line); ++i) {
if (i == 0) {
- data->pid = std::stoull(line);
+ try {
+ data->pid = std::stoull(line);
+ } catch (std::exception& e) { data->pid = 0; }
} else if (i == 1) {
data->wlSocket = line;
} else