aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-07-17 08:46:53 -0700
committerLibravatar GitHub <noreply@github.com>2018-07-17 08:46:53 -0700
commitbec982bba62db39f734d21ffbd2a3c8cefb3f6bd (patch)
treeaff37d623566b7fa85fcdaf78f8ae046fec8cde5
parentMerge pull request #2286 from RyanDwyer/default-floating-border (diff)
parentFix memory leak in sway/desktop/idle_inhibit_v1.c (diff)
downloadsway-bec982bba62db39f734d21ffbd2a3c8cefb3f6bd.tar.gz
sway-bec982bba62db39f734d21ffbd2a3c8cefb3f6bd.tar.zst
sway-bec982bba62db39f734d21ffbd2a3c8cefb3f6bd.zip
Merge pull request #2289 from frsfnrrg/memory-fixes1.0-alpha.4
Fix memory leaks and reference to uninitialized
-rw-r--r--sway/config.c8
-rw-r--r--sway/criteria.c2
-rw-r--r--sway/desktop/idle_inhibit_v1.c1
-rw-r--r--sway/desktop/layer_shell.c12
-rw-r--r--sway/tree/view.c4
5 files changed, 17 insertions, 10 deletions
diff --git a/sway/config.c b/sway/config.c
index 2c051146..c620e4c7 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -24,6 +24,7 @@
24#include "sway/input/seat.h" 24#include "sway/input/seat.h"
25#include "sway/commands.h" 25#include "sway/commands.h"
26#include "sway/config.h" 26#include "sway/config.h"
27#include "sway/criteria.h"
27#include "sway/tree/arrange.h" 28#include "sway/tree/arrange.h"
28#include "sway/tree/layout.h" 29#include "sway/tree/layout.h"
29#include "sway/tree/workspace.h" 30#include "sway/tree/workspace.h"
@@ -105,7 +106,12 @@ void free_config(struct sway_config *config) {
105 } 106 }
106 list_free(config->seat_configs); 107 list_free(config->seat_configs);
107 } 108 }
108 list_free(config->criteria); 109 if (config->criteria) {
110 for (int i = 0; i < config->criteria->length; ++i) {
111 criteria_destroy(config->criteria->items[i]);
112 }
113 list_free(config->criteria);
114 }
109 list_free(config->no_focus); 115 list_free(config->no_focus);
110 list_free(config->active_bar_modifiers); 116 list_free(config->active_bar_modifiers);
111 list_free(config->config_chain); 117 list_free(config->config_chain);
diff --git a/sway/criteria.c b/sway/criteria.c
index c999d248..e2b248de 100644
--- a/sway/criteria.c
+++ b/sway/criteria.c
@@ -37,7 +37,7 @@ void criteria_destroy(struct criteria *criteria) {
37 pcre_free(criteria->con_mark); 37 pcre_free(criteria->con_mark);
38 pcre_free(criteria->window_role); 38 pcre_free(criteria->window_role);
39 free(criteria->workspace); 39 free(criteria->workspace);
40 40 free(criteria->cmdlist);
41 free(criteria->raw); 41 free(criteria->raw);
42 free(criteria); 42 free(criteria);
43} 43}
diff --git a/sway/desktop/idle_inhibit_v1.c b/sway/desktop/idle_inhibit_v1.c
index 108a8417..da17d0f2 100644
--- a/sway/desktop/idle_inhibit_v1.c
+++ b/sway/desktop/idle_inhibit_v1.c
@@ -67,6 +67,7 @@ struct sway_idle_inhibit_manager_v1 *sway_idle_inhibit_manager_v1_create(
67 67
68 manager->wlr_manager = wlr_idle_inhibit_v1_create(wl_display); 68 manager->wlr_manager = wlr_idle_inhibit_v1_create(wl_display);
69 if (!manager->wlr_manager) { 69 if (!manager->wlr_manager) {
70 free(manager);
70 return NULL; 71 return NULL;
71 } 72 }
72 manager->idle = idle; 73 manager->idle = idle;
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index 91baa6f8..a7d96717 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -325,12 +325,6 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
325 layer_surface->client_pending.margin.bottom, 325 layer_surface->client_pending.margin.bottom,
326 layer_surface->client_pending.margin.left); 326 layer_surface->client_pending.margin.left);
327 327
328 struct sway_layer_surface *sway_layer =
329 calloc(1, sizeof(struct sway_layer_surface));
330 if (!sway_layer) {
331 return;
332 }
333
334 if (!layer_surface->output) { 328 if (!layer_surface->output) {
335 // Assign last active output 329 // Assign last active output
336 struct sway_container *output = NULL; 330 struct sway_container *output = NULL;
@@ -352,6 +346,12 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
352 layer_surface->output = output->sway_output->wlr_output; 346 layer_surface->output = output->sway_output->wlr_output;
353 } 347 }
354 348
349 struct sway_layer_surface *sway_layer =
350 calloc(1, sizeof(struct sway_layer_surface));
351 if (!sway_layer) {
352 return;
353 }
354
355 sway_layer->surface_commit.notify = handle_surface_commit; 355 sway_layer->surface_commit.notify = handle_surface_commit;
356 wl_signal_add(&layer_surface->surface->events.commit, 356 wl_signal_add(&layer_surface->surface->events.commit,
357 &sway_layer->surface_commit); 357 &sway_layer->surface_commit);
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 70ab9364..fc31699c 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -621,16 +621,16 @@ void view_unmap(struct sway_view *view) {
621 view->urgent_timer = NULL; 621 view->urgent_timer = NULL;
622 } 622 }
623 623
624 struct sway_container *parent;
625 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); 624 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
626 625
626 struct sway_container *parent;
627 if (view->is_fullscreen) { 627 if (view->is_fullscreen) {
628 ws->sway_workspace->fullscreen = NULL; 628 ws->sway_workspace->fullscreen = NULL;
629 parent = container_destroy(view->swayc); 629 parent = container_destroy(view->swayc);
630 630
631 arrange_windows(ws->parent); 631 arrange_windows(ws->parent);
632 } else { 632 } else {
633 struct sway_container *parent = container_destroy(view->swayc); 633 parent = container_destroy(view->swayc);
634 arrange_windows(parent); 634 arrange_windows(parent);
635 } 635 }
636 if (parent->type >= C_WORKSPACE) { // if the workspace still exists 636 if (parent->type >= C_WORKSPACE) { // if the workspace still exists