From b8ce2c9cd247d2f4d8a7468a5e8a3f47c0c821e9 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Sat, 9 Sep 2017 21:24:25 -0400 Subject: [PATCH] fookb: Fix error handling when reading XPM files. Previously, we would try and read the width and height of images read from an XPM file *before* doing any error handling to determine whether we successfully read the file in the first place. If there had been an error, then there would be a segfault. --- fookb/images.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fookb/images.c b/fookb/images.c index d052a30..8f24949 100644 --- a/fookb/images.c +++ b/fookb/images.c @@ -38,6 +38,9 @@ static int get_one_image(char *name, int index, Display *dpy) foo = XpmReadFileToImage(dpy, name, &stupid_picture[index], NULL, NULL); + if (foo < 0) + return foo; + if (0 == w) { w = stupid_picture[index]->width; if (0 == w) {