From 90f04657ad3cac36ca1bfa96f62f3878166bc8f6 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Wed, 15 Feb 2023 18:37:37 +0100 Subject: [PATCH] Fix coverity issue 1. Close file descriptor in case of error --- filter/foomatic-rip/foomaticrip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/filter/foomatic-rip/foomaticrip.c b/filter/foomatic-rip/foomaticrip.c index b6abe4d33..036d6138b 100644 --- a/filter/foomatic-rip/foomaticrip.c +++ b/filter/foomatic-rip/foomaticrip.c @@ -639,7 +639,7 @@ int print_file(const char *filename, int convert) { - FILE *file; + FILE *file = NULL; char buf[8192]; char tmpfilename[PATH_MAX] = ""; int type; @@ -664,6 +664,8 @@ print_file(const char *filename, n = fread_or_die(buf, 1, sizeof(buf) - 1, file); if (!n) { _log("Input is empty, outputting empty file.\n"); + if (strcasecmp(filename, "")) + fclose(file); return (1); } buf[n] = '\0'; -- 2.47.3