[hackers] [sent] fix more memory leaks || Markus Teich

From: <git_AT_suckless.org>
Date: Wed, 11 Nov 2015 19:15:33 +0100 (CET)

commit d7eac23083be2278327e94255a182a221a0df273
Author: Markus Teich <markus.teich_AT_stusta.mhn.de>
AuthorDate: Wed Nov 11 19:09:13 2015 +0100
Commit: Markus Teich <markus.teich_AT_stusta.mhn.de>
CommitDate: Wed Nov 11 19:09:13 2015 +0100

    fix more memory leaks

diff --git a/sent.c b/sent.c
index 7a85a3f..8ef7e33 100644
--- a/sent.c
+++ b/sent.c
_AT_@ -142,6 +142,7 @@ Image *pngopen(char *filename)
                 return NULL;
 
         img = malloc(sizeof(Image));
+ memset(img, 0, sizeof(Image));
         if (!(img->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
                                         NULL, NULL))) {
                 free(img);
_AT_@ -166,6 +167,9 @@ Image *pngopen(char *filename)
 void pngfree(Image *img)
 {
         png_destroy_read_struct(&img->png_ptr, img->info_ptr ? &img->info_ptr : NULL, NULL);
+ free(img->buf);
+ if (img->ximg)
+ XDestroyImage(img->ximg);
         free(img);
 }
 
_AT_@ -344,6 +348,8 @@ void cleanup()
         XCloseDisplay(xw.dpy);
         if (slides) {
                 for (i = 0; i < slidecount; i++) {
+ if (slides[i].text)
+ free(slides[i].text);
                         if (slides[i].img)
                                 pngfree(slides[i].img);
                 }
_AT_@ -408,8 +414,6 @@ void load(FILE *fp)
                         slides[i].img = 0;
                 i++;
         }
- if (slides)
- slides[i].text = NULL;
         slidecount = i;
 }
 
Received on Wed Nov 11 2015 - 19:15:33 CET

This archive was generated by hypermail 2.3.0 : Wed Nov 11 2015 - 19:24:19 CET