wmbiff: Fix memory leaks pointed out by valgrind.

This commit is contained in:
Gabriel VLASIU 2013-04-04 13:56:46 +03:00 committed by Carlos R. Mafra
parent 8b1a26f4ba
commit 55ae2b61fe
2 changed files with 15 additions and 0 deletions

View 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);
}
}

View 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);
}