Merge pull request #2289 from frsfnrrg/memory-fixes

Fix memory leaks and reference to uninitialized
This commit is contained in:
Drew DeVault 2018-07-17 08:46:53 -07:00 committed by GitHub
commit bec982bba6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 10 deletions

View file

@ -24,6 +24,7 @@
#include "sway/input/seat.h"
#include "sway/commands.h"
#include "sway/config.h"
#include "sway/criteria.h"
#include "sway/tree/arrange.h"
#include "sway/tree/layout.h"
#include "sway/tree/workspace.h"
@ -105,7 +106,12 @@ void free_config(struct sway_config *config) {
}
list_free(config->seat_configs);
}
list_free(config->criteria);
if (config->criteria) {
for (int i = 0; i < config->criteria->length; ++i) {
criteria_destroy(config->criteria->items[i]);
}
list_free(config->criteria);
}
list_free(config->no_focus);
list_free(config->active_bar_modifiers);
list_free(config->config_chain);

View file

@ -37,7 +37,7 @@ void criteria_destroy(struct criteria *criteria) {
pcre_free(criteria->con_mark);
pcre_free(criteria->window_role);
free(criteria->workspace);
free(criteria->cmdlist);
free(criteria->raw);
free(criteria);
}

View file

@ -67,6 +67,7 @@ struct sway_idle_inhibit_manager_v1 *sway_idle_inhibit_manager_v1_create(
manager->wlr_manager = wlr_idle_inhibit_v1_create(wl_display);
if (!manager->wlr_manager) {
free(manager);
return NULL;
}
manager->idle = idle;

View file

@ -325,12 +325,6 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
layer_surface->client_pending.margin.bottom,
layer_surface->client_pending.margin.left);
struct sway_layer_surface *sway_layer =
calloc(1, sizeof(struct sway_layer_surface));
if (!sway_layer) {
return;
}
if (!layer_surface->output) {
// Assign last active output
struct sway_container *output = NULL;
@ -352,6 +346,12 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
layer_surface->output = output->sway_output->wlr_output;
}
struct sway_layer_surface *sway_layer =
calloc(1, sizeof(struct sway_layer_surface));
if (!sway_layer) {
return;
}
sway_layer->surface_commit.notify = handle_surface_commit;
wl_signal_add(&layer_surface->surface->events.commit,
&sway_layer->surface_commit);

View file

@ -621,16 +621,16 @@ void view_unmap(struct sway_view *view) {
view->urgent_timer = NULL;
}
struct sway_container *parent;
struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
struct sway_container *parent;
if (view->is_fullscreen) {
ws->sway_workspace->fullscreen = NULL;
parent = container_destroy(view->swayc);
arrange_windows(ws->parent);
} else {
struct sway_container *parent = container_destroy(view->swayc);
parent = container_destroy(view->swayc);
arrange_windows(parent);
}
if (parent->type >= C_WORKSPACE) { // if the workspace still exists