aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-07-06 08:43:33 -0700
committerGitHub <noreply@github.com>2018-07-06 08:43:33 -0700
commit817e847749240a0c04756c37c88dc554efc56c9e (patch)
treeef2a716f8ea06ce8bdc63d1a682901b24e5bfcf0
parent55c54bb63b82ee75e1893b48b3ce18f7317c6199 (diff)
parentb3c55dd909b070625c9bfcebcb89cb8463e2ffc9 (diff)
Merge pull request #2206 from martinetd/leaks
Fix a bunch of leaks
-rw-r--r--include/sway/commands.h2
-rw-r--r--sway/commands.c8
-rw-r--r--sway/config.c7
-rw-r--r--sway/config/bar.c1
-rw-r--r--sway/input/keyboard.c3
-rw-r--r--sway/ipc-server.c12
-rw-r--r--sway/main.c3
-rw-r--r--sway/tree/container.c1
-rw-r--r--sway/tree/view.c2
-rw-r--r--sway/tree/workspace.c2
10 files changed, 30 insertions, 11 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 7ca0bda8..6d17144a 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -79,7 +79,7 @@ void free_cmd_results(struct cmd_results *results);
*
* Free the JSON string later on.
*/
-const char *cmd_results_to_json(struct cmd_results *results);
+char *cmd_results_to_json(struct cmd_results *results);
struct cmd_results *add_color(const char *name,
char *buffer, const char *color);
diff --git a/sway/commands.c b/sway/commands.c
index 5b67e1ec..ef477f38 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -527,7 +527,7 @@ void free_cmd_results(struct cmd_results *results) {
free(results);
}
-const char *cmd_results_to_json(struct cmd_results *results) {
+char *cmd_results_to_json(struct cmd_results *results) {
json_object *result_array = json_object_new_array();
json_object *root = json_object_new_object();
json_object_object_add(root, "success",
@@ -542,9 +542,9 @@ const char *cmd_results_to_json(struct cmd_results *results) {
}
json_object_array_add(result_array, root);
const char *json = json_object_to_json_string(result_array);
- free(result_array);
- free(root);
- return json;
+ char *res = strdup(json);
+ json_object_put(result_array);
+ return res;
}
/**
diff --git a/sway/config.c b/sway/config.c
index 0aae1696..89b7d349 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -87,7 +87,12 @@ void free_config(struct sway_config *config) {
list_free(config->cmd_queue);
list_free(config->workspace_outputs);
list_free(config->pid_workspaces);
- list_free(config->output_configs);
+ if (config->output_configs) {
+ for (int i = 0; i < config->output_configs->length; i++) {
+ free_output_config(config->output_configs->items[i]);
+ }
+ list_free(config->output_configs);
+ }
if (config->input_configs) {
for (int i = 0; i < config->input_configs->length; i++) {
free_input_config(config->input_configs->items[i]);
diff --git a/sway/config/bar.c b/sway/config/bar.c
index b97076a0..ee062c6a 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -30,6 +30,7 @@ void free_bar_config(struct bar_config *bar) {
if (!bar) {
return;
}
+ free(bar->id);
free(bar->mode);
free(bar->position);
free(bar->hidden_state);
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index ec149d06..182536de 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -420,6 +420,9 @@ void sway_keyboard_destroy(struct sway_keyboard *keyboard) {
if (!keyboard) {
return;
}
+ if (keyboard->keymap) {
+ xkb_keymap_unref(keyboard->keymap);
+ }
wl_list_remove(&keyboard->keyboard_key.link);
wl_list_remove(&keyboard->keyboard_modifiers.link);
free(keyboard);
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 8cfd9f26..abdaa237 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -64,6 +64,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
close(ipc_socket);
unlink(ipc_sockaddr->sun_path);
+ while (ipc_client_list->length) {
+ struct ipc_client *client = ipc_client_list->items[0];
+ ipc_client_disconnect(client);
+ }
list_free(ipc_client_list);
if (ipc_sockaddr) {
@@ -479,10 +483,10 @@ void ipc_client_handle_command(struct ipc_client *client) {
case IPC_COMMAND:
{
struct cmd_results *results = execute_command(buf, NULL);
- const char *json = cmd_results_to_json(results);
- char reply[256];
- int length = snprintf(reply, sizeof(reply), "%s", json);
- client_valid = ipc_send_reply(client, reply, (uint32_t)length);
+ char *json = cmd_results_to_json(results);
+ int length = strlen(json);
+ client_valid = ipc_send_reply(client, json, (uint32_t)length);
+ free(json);
free_cmd_results(results);
goto exit_cleanup;
}
diff --git a/sway/main.c b/sway/main.c
index 96e41bbc..ec7353be 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -1,6 +1,7 @@
#define _XOPEN_SOURCE 700
#define _POSIX_C_SOURCE 200112L
#include <getopt.h>
+#include <pango/pangocairo.h>
#include <signal.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -441,5 +442,7 @@ int main(int argc, char **argv) {
free_config(config);
}
+ pango_cairo_font_map_set_default(NULL);
+
return exit_value;
}
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 3614d4e7..9093feba 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -151,6 +151,7 @@ void container_free(struct sway_container *cont) {
return;
}
free(cont->name);
+ free(cont->formatted_title);
wlr_texture_destroy(cont->title_focused);
wlr_texture_destroy(cont->title_focused_inactive);
wlr_texture_destroy(cont->title_unfocused);
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 6b4daa82..bca8ef8a 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -514,7 +514,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
if (container_is_floating(focus)) {
focus = focus->parent->parent;
}
- free(criterias);
+ list_free(criterias);
cont = container_view_create(focus, view);
view->surface = wlr_surface;
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 2db06a31..51f0fcb4 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -191,6 +191,8 @@ char *workspace_next_name(const char *output_name) {
free(target);
target = _target;
wlr_log(L_DEBUG, "Workspace: Found free name %s", _target);
+ } else {
+ free(_target);
}
}
free(dup);