On Mon, Apr 22, 2019 at 03:13:00AM +0000, Linda Lapinlampi wrote:
> Finally, the "1.0" in master branch in VCS is currently unusable for two
> additional reasons:

Actually three, and the third reason is upstream's 1.0 version is broken
because of -Werror=alloc-size-larger-than= in swaybar/tray/icon.c.

https://github.com/swaywm/sway/issues/3862
https://github.com/swaywm/sway/commit/bcde298a719f60b9913133dbd2a169dedbc8dd7d

I'm attaching a DEP-3 patch for 1.0 (although you could in theory "just"
make a package release with version number 1.0+bcde298 instead, it's
one commit ahead of the 1.0 Git tag it seems).
Bug: https://github.com/swaywm/sway/issues/3862
Bug-Debian: https://bugs.debian.org/927723
Origin: upstream, https://github.com/swaywm/sway/commit/bcde298
From: emersion <cont...@emersion.fr>
Subject: Fix size_t temporary underflow in log_loaded_themes

`len` will underflow but will overflow right after, so it's not as bad as it
may appear. Still better not to under/overflow at all.

Fixes https://github.com/swaywm/sway/issues/3862
---
 swaybar/tray/icon.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/swaybar/tray/icon.c b/swaybar/tray/icon.c
index c7ce20b4d..2276e36de 100644
--- a/swaybar/tray/icon.c
+++ b/swaybar/tray/icon.c
@@ -307,16 +307,16 @@ static void log_loaded_themes(list_t *themes) {
 		return;
 	}
 
-	const char *sep = ", ";
+	const char sep[] = ", ";
 	size_t sep_len = strlen(sep);
 
-	size_t len = 1 - sep_len;
+	size_t len = 0;
 	for (int i = 0; i < themes->length; ++i) {
 		struct icon_theme *theme = themes->items[i];
 		len += strlen(theme->name) + sep_len;
 	}
 
-	char *str = malloc(len);
+	char *str = malloc(len + 1);
 	if (!str) {
 		return;
 	}

Reply via email to