From c068f47ce392dab0374b619d6a501ab6974749cc Mon Sep 17 00:00:00 2001 From: Alexander 'z33ky' Hirsch <1zeeky@gmail.com> Date: Thu, 20 Aug 2015 02:10:45 +0200 Subject: [PATCH 1/3] Fix potential crash when toggling fullscreen mode --- sway/handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/handlers.c b/sway/handlers.c index a6dbf94c..0bb181cc 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -290,8 +290,8 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s // i3 just lets it become fullscreen wlc_view_set_state(view, state, toggle); c = get_swayc_for_handle(view, &root_container); - sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d", view, c->name, toggle); if (c) { + sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d", view, c->name, toggle); arrange_windows(c->parent, -1, -1); // Set it as focused window for that workspace if its going fullscreen if (toggle) { From 22675b01118766c980d9c9c66453fb5d5318cdef Mon Sep 17 00:00:00 2001 From: Alexander 'z33ky' Hirsch <1zeeky@gmail.com> Date: Thu, 20 Aug 2015 02:17:46 +0200 Subject: [PATCH 2/3] Minor style fix --- sway/log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sway/log.c b/sway/log.c index 9b9a9dc0..44f6e366 100644 --- a/sway/log.c +++ b/sway/log.c @@ -19,10 +19,10 @@ static const char *verbosity_colors[] = { void init_log(int verbosity) { v = verbosity; /* set FD_CLOEXEC flag to prevent programs called with exec to write into logs */ - int i, flag; + int i; int fd[] = { STDOUT_FILENO, STDIN_FILENO, STDERR_FILENO }; for (i = 0; i < 3; ++i) { - flag = fcntl(fd[i], F_GETFD); + int flag = fcntl(fd[i], F_GETFD); if (flag != -1) { fcntl(fd[i], F_SETFD, flag | FD_CLOEXEC); } From f85d0740a83c32f9ef4d7f73b3dd25cff3a6239a Mon Sep 17 00:00:00 2001 From: Alexander 'z33ky' Hirsch <1zeeky@gmail.com> Date: Thu, 20 Aug 2015 02:24:47 +0200 Subject: [PATCH 3/3] Fix potential memory leak --- sway/readline.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sway/readline.c b/sway/readline.c index dfdc3fe8..e75b183f 100644 --- a/sway/readline.c +++ b/sway/readline.c @@ -17,18 +17,22 @@ char *read_line(FILE *file) { continue; } if (length == size) { - string = realloc(string, size *= 2); - if (!string) { + char *new_string = realloc(string, size *= 2); + if (!new_string) { + free(string); return NULL; } + string = new_string; } string[length++] = c; } if (length + 1 == size) { - string = realloc(string, length + 1); - if (!string) { + char *new_string = realloc(string, length + 1); + if (!new_string) { + free(string); return NULL; } + string = new_string; } string[length] = '\0'; return string;