From cbe3940d828a48aad7aa55bca3b0f40019d58021 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 10 Sep 2023 19:47:25 +0200 Subject: [PATCH] Fix iteration over monitor list Ensure the code runs on the very last element of the list. Closes #245 --- lemonbar.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lemonbar.c b/lemonbar.c index 9480647..4657683 100644 --- a/lemonbar.c +++ b/lemonbar.c @@ -599,12 +599,14 @@ parse (char *text) case 'n': { // Named monitor. const size_t name_len = block_end - (p + 1); cur_mon = monhead; - while (cur_mon->next) { + while (cur_mon) { if (cur_mon->name && - !strncmp(cur_mon->name, p + 1, name_len)) + !strncmp(cur_mon->name, p + 1, name_len) && + cur_mon->name[name_len] == '\0') break; cur_mon = cur_mon->next; } + if (!cur_mon) cur_mon = orig_mon; p += 1 + name_len; } break; case '0' ... '9': // Numbered monitor.