#986349 db.c: always close file pointer "actfp"

Package:
src:nn
Source:
nn
Submitter:
Bjarni Ingi Gislason
Date:
2021-04-04 00:00:04 UTC
Severity:
normal
Tags:
#986349#5
Date:
2021-04-03 23:56:22 UTC
From:
To:
Dear Maintainer,

  File pointer "actfp" is opened independent of the use of NNTP or not
("use_nntp").

  Should silence a warning:

db.c:1252:12: warning: leak of FILE 'actfp' [CWE-775] [-Wanalyzer-file-leak]
 1252 |     grplist[count] = NULL;
      |            ^
...
           | 1251 |     actlist[count] = NULL;
           | 1252 |     grplist[count] = NULL;
           |      |            ~
           |      |            |
           |      |            (26) 'actfp' leaks here; was opened at (10)

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 db.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/db.c b/db.c
index 15a9372..bd10cc4 100644
--- a/db.c
+++ b/db.c
@@ -1092,8 +1092,7 @@ readactfile(void)
     }
     stp->n.next = NULL;

-    if (!use_nntp)
-	(void) fclose(actfp);
+    (void) fclose(actfp);

     actlist = (char **) calloc(count + 1, sizeof(char *));
     grplist = (char **) calloc(count + 1, sizeof(char *));
@@ -1218,8 +1217,7 @@ readpartactfile(void)
     }
     stp->n.next = NULL;

-    if (!use_nntp)
-	(void) fclose(actfp);
+    (void) fclose(actfp);

     actlist = (char **) calloc(count + 1, sizeof(char *));
     grplist = (char **) calloc(count + 1, sizeof(char *));