swaynag: fix segfault on exit when arguments are not correct

swaynag_destroy is called on all cleanup cases and needs the lists to be valid,
just init them early
This commit is contained in:
Dominique Martinet 2020-03-29 09:53:52 +02:00 committed by Simon Ser
parent 214e3030e1
commit 484f7677b0
2 changed files with 2 additions and 2 deletions

View file

@ -27,6 +27,8 @@ int main(int argc, char **argv) {
memset(&swaynag, 0, sizeof(swaynag)); memset(&swaynag, 0, sizeof(swaynag));
swaynag.buttons = create_list(); swaynag.buttons = create_list();
wl_list_init(&swaynag.outputs);
wl_list_init(&swaynag.seats);
struct swaynag_button *button_close = struct swaynag_button *button_close =
calloc(sizeof(struct swaynag_button), 1); calloc(sizeof(struct swaynag_button), 1);

View file

@ -437,8 +437,6 @@ void swaynag_setup(struct swaynag *swaynag) {
} }
swaynag->scale = 1; swaynag->scale = 1;
wl_list_init(&swaynag->outputs);
wl_list_init(&swaynag->seats);
struct wl_registry *registry = wl_display_get_registry(swaynag->display); struct wl_registry *registry = wl_display_get_registry(swaynag->display);
wl_registry_add_listener(registry, &registry_listener, swaynag); wl_registry_add_listener(registry, &registry_listener, swaynag);