about summary refs log tree commit diff
diff options
context:
space:
mode:
authortim <tim>2020-03-13 20:49:13 +0000
committertim <tim>2020-03-13 20:49:13 +0000
commitd8c7d877379385cdf30d84498db5e7f2e6da28b9 (patch)
tree79bbdeb4d1c344884f3f278f8f209193679748e5
parent3d1a8028c2cf9921ba66e7c0e8a76523a4ecde1e (diff)
downloadcwm-d8c7d877379385cdf30d84498db5e7f2e6da28b9.tar.gz
cwm-d8c7d877379385cdf30d84498db5e7f2e6da28b9.tar.xz
cwm-d8c7d877379385cdf30d84498db5e7f2e6da28b9.zip
Plug two memory leaks. Also get rid of a variable that is no longer
necessary.

OK okan@
-rw-r--r--client.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/client.c b/client.c
index 653c0d4..ea97344 100644
--- a/client.c
+++ b/client.c
@@ -668,21 +668,23 @@ void
 client_set_name(struct client_ctx *cc)
 {
 	struct winname	*wn;
-	char		*newname;
 	int		 i = 0;
 
-	if (!xu_get_strprop(cc->win, ewmh[_NET_WM_NAME], &newname))
-		if (!xu_get_strprop(cc->win, XA_WM_NAME, &newname))
-			newname = xstrdup("");
+	free(cc->name);
+	if (!xu_get_strprop(cc->win, ewmh[_NET_WM_NAME], &cc->name))
+		if (!xu_get_strprop(cc->win, XA_WM_NAME, &cc->name))
+			cc->name = xstrdup("");
 
 	TAILQ_FOREACH(wn, &cc->nameq, entry) {
-		if (strcmp(wn->name, newname) == 0)
+		if (strcmp(wn->name, cc->name) == 0) {
 			TAILQ_REMOVE(&cc->nameq, wn, entry);
+			free(wn->name);
+			free(wn);
+		}
 		i++;
 	}
-	cc->name = newname;
 	wn = xmalloc(sizeof(*wn));
-	wn->name = xstrdup(newname);
+	wn->name = xstrdup(cc->name);
 	TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
 
 	/* Garbage collection. */