[hackers] [st] fix memory leak in xloadcols() || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sun, 4 Nov 2018 14:41:03 +0100 (CET)

commit d7bf023b2f2d41cb6983bb3ce2c6d1bf049150b3
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Sun Nov 4 14:35:07 2018 +0100
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Sun Nov 4 14:35:07 2018 +0100

    fix memory leak in xloadcols()
    
    reported by Avi Halachmi (:avih)" <avihpit_AT_yahoo.com>
    
    patch slightly changed by me.

diff --git a/x.c b/x.c
index 00cb6b1..0422421 100644
--- a/x.c
+++ b/x.c
_AT_@ -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++)
Received on Sun Nov 04 2018 - 14:41:03 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 04 2018 - 14:48:22 CET