aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar
diff options
context:
space:
mode:
authorLibravatar M Stoeckl <code@mstoeckl.com>2019-01-18 21:05:50 -0500
committerLibravatar emersion <contact@emersion.fr>2019-01-19 08:42:52 +0100
commit695948e6891e0ec955f1fdc0771303cdaf19d026 (patch)
treef4e136821094714845eed02790788638271bad8e /swaybar
parentPrevent crashes in handle_transform and handle_scale too (diff)
downloadsway-695948e6891e0ec955f1fdc0771303cdaf19d026.tar.gz
sway-695948e6891e0ec955f1fdc0771303cdaf19d026.tar.zst
sway-695948e6891e0ec955f1fdc0771303cdaf19d026.zip
Fix memory leaks in swaybar
Diffstat (limited to 'swaybar')
-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) {
191 size_t path_len = snprintf(NULL, 0, "%s/%s/index.theme", basedir, 191 size_t path_len = snprintf(NULL, 0, "%s/%s/index.theme", basedir,
192 theme_name) + 1; 192 theme_name) + 1;
193 char *path = malloc(path_len); 193 char *path = malloc(path_len);
194 if (!path) {
195 return NULL;
196 }
194 snprintf(path, path_len, "%s/%s/index.theme", basedir, theme_name); 197 snprintf(path, path_len, "%s/%s/index.theme", basedir, theme_name);
195 FILE *theme_file = fopen(path, "r"); 198 FILE *theme_file = fopen(path, "r");
199 free(path);
196 if (!theme_file) { 200 if (!theme_file) {
197 return NULL; 201 return NULL;
198 } 202 }
@@ -293,6 +297,7 @@ static list_t *load_themes_in_dir(char *basedir) {
293 list_add(themes, theme); 297 list_add(themes, theme);
294 } 298 }
295 } 299 }
300 closedir(dir);
296 return themes; 301 return themes;
297} 302}
298 303
@@ -311,7 +316,9 @@ void init_themes(list_t **themes, list_t **basedirs) {
311 struct icon_theme *theme = (*themes)->items[i]; 316 struct icon_theme *theme = (*themes)->items[i];
312 list_add(theme_names, theme->name); 317 list_add(theme_names, theme->name);
313 } 318 }
314 wlr_log(WLR_DEBUG, "Loaded themes: %s", join_list(theme_names, ", ")); 319 char *theme_list = join_list(theme_names, ", ");
320 wlr_log(WLR_DEBUG, "Loaded themes: %s", theme_list);
321 free(theme_list);
315 list_free(theme_names); 322 list_free(theme_names);
316} 323}
317 324