From 6d2b82253a5f2fb0ab8e63ded2b62e5d4088e63b Mon Sep 17 00:00:00 2001
From: Dominique Martinet <asmadeus@codewreck.org>
Date: Sun, 1 Jul 2018 23:09:17 +0900
Subject: bar_cmd_font: fix leak of font

join_args is a freshly allocated string and can be used as is.

Found through static analysis.
---
 sway/commands/bar/font.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'sway/commands/bar')

diff --git a/sway/commands/bar/font.c b/sway/commands/bar/font.c
index 80b7a593..f036cbc3 100644
--- a/sway/commands/bar/font.c
+++ b/sway/commands/bar/font.c
@@ -14,7 +14,7 @@ struct cmd_results *bar_cmd_font(int argc, char **argv) {
 	}
 	char *font = join_args(argv, argc);
 	free(config->current_bar->font);
-	config->current_bar->font = strdup(font);
+	config->current_bar->font = font;
 	wlr_log(L_DEBUG, "Settings font '%s' for bar: %s",
 			config->current_bar->font, config->current_bar->id);
 	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
-- 
cgit v1.2.3


From c73c552cae435dd61ebbe0c76aa66570095375a9 Mon Sep 17 00:00:00 2001
From: Dominique Martinet <asmadeus@codewreck.org>
Date: Sun, 1 Jul 2018 23:12:17 +0900
Subject: bar_cmd_modifier: fix use-after-free on error

Found through static analysis.
---
 sway/commands/bar/modifier.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'sway/commands/bar')

diff --git a/sway/commands/bar/modifier.c b/sway/commands/bar/modifier.c
index 7ba4b125..02f845e6 100644
--- a/sway/commands/bar/modifier.c
+++ b/sway/commands/bar/modifier.c
@@ -22,9 +22,10 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
 			mod |= tmp_mod;
 			continue;
 		} else {
+			error = cmd_results_new(CMD_INVALID, "modifier",
+				"Unknown modifier '%s'", split->items[i]);
 			free_flat_list(split);
-			return cmd_results_new(CMD_INVALID, "modifier",
-					"Unknown modifier '%s'", split->items[i]);
+			return error;
 		}
 	}
 	free_flat_list(split);
-- 
cgit v1.2.3