From 4b28eaa7bd505129589febd3433d23ea7e289a28 Mon Sep 17 00:00:00 2001 From: Mikhail Efremov Date: Wed, 23 Aug 2023 17:40:42 +0300 Subject: [PATCH] Fix tests build with glibc 2.38 Fixed warning: use of possibly-NULL where non-null expected [CWE-690] [-Werror=analyzer-possible-null-argument]. --- tests/Test_parser.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/Test_parser.c b/tests/Test_parser.c index b0b4e7a..3bf53a9 100644 --- a/tests/Test_parser.c +++ b/tests/Test_parser.c @@ -146,6 +146,8 @@ createFile (int lineNumber, const char *line) fileIn = fopen (fileCorrectName, "r"); fileOut = fopen (fileErroredName, "w"); + if (fileIn == NULL || fileOut == NULL) + goto out; while (readLine (fileIn, lineRead) != EOF) { @@ -156,8 +158,11 @@ createFile (int lineNumber, const char *line) fprintf (fileOut, "%s\n", lineRead); } - fclose (fileOut); - fclose (fileIn); +out: + if (fileOut) + fclose (fileOut); + if (fileIn) + fclose (fileIn); } static int -- 2.33.8