Merge pull request #2184 from lfos/fix-battery-segfault

Fix SEGFAULT in battery module
This commit is contained in:
Alex 2023-05-22 16:19:13 +02:00 committed by GitHub
commit 7b0d2e8043
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -36,7 +36,8 @@ waybar::modules::Battery::~Battery() {
} }
close(global_watch_fd_); close(global_watch_fd_);
for (auto it = batteries_.cbegin(); it != batteries_.cend(); it++) { for (auto it = batteries_.cbegin(), next_it = it; it != batteries_.cend(); it = next_it) {
++next_it;
auto watch_id = (*it).second; auto watch_id = (*it).second;
if (watch_id >= 0) { if (watch_id >= 0) {
inotify_rm_watch(battery_watch_fd_, watch_id); inotify_rm_watch(battery_watch_fd_, watch_id);