Skip to content
Permalink
Browse files

alttab: Add memleaks patch

Signed-off-by: Nathan Owens <ndowens04@gmail.com>
  • Loading branch information
ndowens authored and Hoshpak committed Dec 3, 2019
1 parent 3fb586d commit fd45c92d987d405bf3c11ecd3e5dfabce3d8e072
@@ -0,0 +1,41 @@
From 980bdef0fde36772e283e36a7e12ce28ff1901aa Mon Sep 17 00:00:00 2001
From: Michael Vetter <jubalh@iodoru.org>
Date: Thu, 3 Oct 2019 17:25:19 +0200
Subject: [PATCH] Fix memleaks in error case

We should free img.data.
---
src/pngd.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/src/pngd.c b/src/pngd.c
index ef46621..fb3fd25 100644
--- src/pngd.c
+++ src/pngd.c
@@ -250,6 +250,7 @@ int pngReadToDrawable(char *pngpath, Drawable d, uint8_t bg_red,
fclose(infile);
if (!img.data || img.width == 0 || img.height == 0) {
fprintf(stderr, "error loading png data\n");
+ pngFree(&img);
return 0;
}
if (debug > 0)
@@ -259,6 +260,7 @@ int pngReadToDrawable(char *pngpath, Drawable d, uint8_t bg_red,
pad = 32;
if (!xdata) {
fprintf(stderr, "xdata malloc error\n");
+ pngFree(&img);
return 0;
}
ximage =
@@ -267,6 +269,7 @@ int pngReadToDrawable(char *pngpath, Drawable d, uint8_t bg_red,
if (!ximage) {
fprintf(stderr, "error creating ximage\n");
free(xdata);
+ pngFree(&img);
return 0;
}
ximage->byte_order = MSBFirst;
--
2.24.0

@@ -0,0 +1,27 @@
From f7e8ff30190a3134863d7ff03becc2e397ec9db0 Mon Sep 17 00:00:00 2001
From: Michael Vetter <jubalh@iodoru.org>
Date: Thu, 3 Oct 2019 17:20:40 +0200
Subject: [PATCH] Remove check around free()

free(NULL) is noop. We don't need to check for this.
---
src/randr.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/randr.c b/src/randr.c
index e4ebe9d..0622c73 100644
--- src/randr.c
+++ src/randr.c
@@ -186,8 +186,7 @@ bool randrGetViewport(quad * res, bool * multihead)
if (no < 1) {
msg(0, "randr didn't detect any output\n");
*multihead = false;
- if (oq != NULL)
- free(oq);
+ free(oq);
return false;
}
if (no == 1) {
--
2.24.0

@@ -1,7 +1,7 @@
# Template file for 'alttab'
pkgname=alttab
version=1.4.0
revision=1
revision=2
build_style=gnu-configure
hostmakedepends="pkg-config"
makedepends="libX11-devel libXft-devel libXmu-devel libXrandr-devel

0 comments on commit fd45c92

Please sign in to comment.
You can’t perform that action at this time.