wmbiff: Fix memory leaks pointed out by valgrind.
authorGabriel VLASIU <gabriel@vlasiu.net>
Thu, 4 Apr 2013 10:56:46 +0000 (4 13:56 +0300)
committerCarlos R. Mafra <crmafra@gmail.com>
Thu, 4 Apr 2013 17:11:13 +0000 (4 18:11 +0100)
wmbiff/wmbiff/wmbiff.c
wmbiff/wmgeneral/wmgeneral.c

index 35b1fa8..b9d216d 100644 (file)
@@ -1168,6 +1168,12 @@ static void do_biff(int argc, const char **argv)
                free(skin_xpm);                 // added 3 jul 02, appeasing valgrind
        }
        if (bkg_xpm != NULL) {
+               // Allocated in CreateBackingXPM()
+               free((void *)bkg_xpm[0]);
+               free((void *)bkg_xpm[2]);
+               int mem_block;
+               for (mem_block = 6; mem_block < 6 + wmbiff_mask_height; mem_block++)
+                       free((void *)bkg_xpm[mem_block]);
                free(bkg_xpm);
        }
 }
index 88d76fe..cb0fd6d 100644 (file)
@@ -469,6 +469,11 @@ void openXwindow(int argc, const char *argv[],
        int dummy = 0;
        int i;
 
+       if (!wname) {
+               fprintf(stderr, "Unable to allocate memory for window name!\n");
+               abort();
+       }
+
        for (i = 1; argv[i]; i++) {
                if (!strcmp(argv[i], "-display")) {
                        display_name = argv[i + 1];
@@ -543,6 +548,7 @@ void openXwindow(int argc, const char *argv[],
        }
 
        XSetWMName(display, win, &name);
+       XFree(name.value);
 
        /* Create GC for drawing */
 
@@ -609,4 +615,7 @@ void openXwindow(int argc, const char *argv[],
                   exit(1);
                   } */
        }
+
+       if (wname)
+               free(wname);
 }