aboutsummaryrefslogtreecommitdiffstats
path: root/swaynag
diff options
context:
space:
mode:
authorLibravatar Greg Depoire--Ferrer <greg@gregdf.com>2022-06-05 10:37:17 +0200
committerLibravatar Simon Ser <contact@emersion.fr>2022-06-05 19:05:26 +0200
commit956b689d6ab18ad78f53f15cdeb7606af98e9e5e (patch)
tree59f2078a820100496a08952f8fecf5db6dfd339e /swaynag
parentRefuse to start when SUID is detected (diff)
downloadsway-956b689d6ab18ad78f53f15cdeb7606af98e9e5e.tar.gz
sway-956b689d6ab18ad78f53f15cdeb7606af98e9e5e.tar.zst
sway-956b689d6ab18ad78f53f15cdeb7606af98e9e5e.zip
swaynag: move close_button up to fix SIGSEGV
When swaynag_parse_options encounters '--dismiss-button' (or its shorthand '-s'), it sets the text of the first button in the swaynag.buttons list, which is expected to exist and to be the dismiss button, to the one passed by the user. Commit 4780afb68b4ee2cdf0e4925f40cf885819f8a74a ("swaynag: statically allocate button_close, and move declaration") moved the list initialization to after swaynag_parse_options is called which made that code fail. For example, the command 'swaynag --dismiss-button Dismiss' crashes and 'swaynag --message Message --button Yes "" --dismiss-button Dismiss' shows the wrong buttons. Move it back to before swaynag_parse_options is called.
Diffstat (limited to 'swaynag')
-rw-r--r--swaynag/main.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/swaynag/main.c b/swaynag/main.c
index 56e4950b..2ce37831 100644
--- a/swaynag/main.c
+++ b/swaynag/main.c
@@ -29,6 +29,11 @@ int main(int argc, char **argv) {
29 wl_list_init(&swaynag.outputs); 29 wl_list_init(&swaynag.outputs);
30 wl_list_init(&swaynag.seats); 30 wl_list_init(&swaynag.seats);
31 31
32 struct swaynag_button button_close = { 0 };
33 button_close.text = strdup("X");
34 button_close.type = SWAYNAG_ACTION_DISMISS;
35 list_add(swaynag.buttons, &button_close);
36
32 char *config_path = NULL; 37 char *config_path = NULL;
33 bool debug = false; 38 bool debug = false;
34 status = swaynag_parse_options(argc, argv, NULL, NULL, NULL, 39 status = swaynag_parse_options(argc, argv, NULL, NULL, NULL,
@@ -85,11 +90,6 @@ int main(int argc, char **argv) {
85 90
86 swaynag_types_free(types); 91 swaynag_types_free(types);
87 92
88 struct swaynag_button button_close = { 0 };
89 button_close.text = strdup("X");
90 button_close.type = SWAYNAG_ACTION_DISMISS;
91 list_add(swaynag.buttons, &button_close);
92
93 if (swaynag.details.message) { 93 if (swaynag.details.message) {
94 list_add(swaynag.buttons, &swaynag.details.button_details); 94 list_add(swaynag.buttons, &swaynag.details.button_details);
95 } 95 }