aboutsummaryrefslogtreecommitdiff
path: root/x.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2018-11-04 14:35:07 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2018-11-04 14:35:07 +0100
commitd7bf023b2f2d41cb6983bb3ce2c6d1bf049150b3 (patch)
tree3727b34ad0bbcfa79d4c9f62ec291a06f5fb17d9 /x.c
parentb4d68d4daa2716c0064605a2a92082a7287ee54a (diff)
downloadst-d7bf023b2f2d41cb6983bb3ce2c6d1bf049150b3.tar.gz
st-d7bf023b2f2d41cb6983bb3ce2c6d1bf049150b3.tar.bz2
fix memory leak in xloadcols()
reported by Avi Halachmi (:avih)" <avihpit@yahoo.com> patch slightly changed by me.
Diffstat (limited to 'x.c')
-rw-r--r--x.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/x.c b/x.c
index 00cb6b1..0422421 100644
--- a/x.c
+++ b/x.c
@@ -733,12 +733,12 @@ xloadcols(void)
static int loaded;
Color *cp;
- dc.collen = MAX(LEN(colorname), 256);
- dc.col = xmalloc(dc.collen * sizeof(Color));
-
if (loaded) {
for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp)
XftColorFree(xw.dpy, xw.vis, xw.cmap, cp);
+ } else {
+ dc.collen = MAX(LEN(colorname), 256);
+ dc.col = xmalloc(dc.collen * sizeof(Color));
}
for (i = 0; i < dc.collen; i++)