From badc1521273305346626b64d0cfd17dd75c6c0a1 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 27 Oct 2019 08:29:43 +0100 Subject: [PATCH] prevent segfault when image fails to load --- src/ptouch-print.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index d0f1940..e8ee6a8 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -1,17 +1,17 @@ /* ptouch-print - Print labels with images or text on a Brother P-Touch - + Copyright (C) 2015-2019 Dominic Radermacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -491,7 +491,10 @@ int main(int argc, char *argv[]) printf("error = %04x\n", ptdev->status->error); exit(0); } else if (strcmp(&argv[i][1], "-image") == 0) { - im=image_load(argv[++i]); + if ((im=image_load(argv[++i])) == NULL) { + printf(_("failed to load image file\n")); + return 1; + } out=img_append(out, im); gdImageDestroy(im); im = NULL;