[PATCH 2/5] cppcheck: close files during shutdown

David Bremner david at tethera.net
Sat Aug 26 07:41:38 PDT 2017


Fix the following cppcheck errors:

    notmuch-count.c:207: error: Resource leak: input
    notmuch-tag.c:238: error: Resource leak: input

We know that the program is shutting down here, but it does no harm to
clean up a bit.
---
 notmuch-count.c | 2 ++
 notmuch-tag.c   | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/notmuch-count.c b/notmuch-count.c
index 50b0c193..97281374 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -204,6 +204,8 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])
 
     if (batch && opt_index != argc) {
 	fprintf (stderr, "--batch and query string are not compatible\n");
+	if (input)
+	    fclose (input);
 	return EXIT_FAILURE;
     }
 
diff --git a/notmuch-tag.c b/notmuch-tag.c
index 9c03754d..130de634 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -235,6 +235,8 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[])
     if (batch) {
 	if (opt_index != argc) {
 	    fprintf (stderr, "Can't specify both cmdline and stdin!\n");
+	    if (input)
+		fclose (input);
 	    return EXIT_FAILURE;
 	}
     } else {
-- 
2.14.1



More information about the notmuch mailing list