aboutsummaryrefslogtreecommitdiff
path: root/swaybar/tray
diff options
context:
space:
mode:
authorM Stoeckl <code@mstoeckl.com>2019-01-18 21:05:50 -0500
committeremersion <contact@emersion.fr>2019-01-19 08:42:52 +0100
commit695948e6891e0ec955f1fdc0771303cdaf19d026 (patch)
treef4e136821094714845eed02790788638271bad8e /swaybar/tray
parent2ae2d09c4cbbf0834f74a3f252fd613d86c5a330 (diff)
Fix memory leaks in swaybar
Diffstat (limited to 'swaybar/tray')
-rw-r--r--swaybar/tray/icon.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/swaybar/tray/icon.c b/swaybar/tray/icon.c
index 67805858..15fda631 100644
--- a/swaybar/tray/icon.c
+++ b/swaybar/tray/icon.c
@@ -191,8 +191,12 @@ static struct icon_theme *read_theme_file(char *basedir, char *theme_name) {
size_t path_len = snprintf(NULL, 0, "%s/%s/index.theme", basedir,
theme_name) + 1;
char *path = malloc(path_len);
+ if (!path) {
+ return NULL;
+ }
snprintf(path, path_len, "%s/%s/index.theme", basedir, theme_name);
FILE *theme_file = fopen(path, "r");
+ free(path);
if (!theme_file) {
return NULL;
}
@@ -293,6 +297,7 @@ static list_t *load_themes_in_dir(char *basedir) {
list_add(themes, theme);
}
}
+ closedir(dir);
return themes;
}
@@ -311,7 +316,9 @@ void init_themes(list_t **themes, list_t **basedirs) {
struct icon_theme *theme = (*themes)->items[i];
list_add(theme_names, theme->name);
}
- wlr_log(WLR_DEBUG, "Loaded themes: %s", join_list(theme_names, ", "));
+ char *theme_list = join_list(theme_names, ", ");
+ wlr_log(WLR_DEBUG, "Loaded themes: %s", theme_list);
+ free(theme_list);
list_free(theme_names);
}