cppcheck: close files during shutdown
authorDavid Bremner <david@tethera.net>
Sat, 26 Aug 2017 14:41:38 +0000 (11:41 -0300)
committerDavid Bremner <david@tethera.net>
Wed, 30 Aug 2017 10:10:07 +0000 (07:10 -0300)
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
notmuch-tag.c

index 50b0c193f04625c794b9ab9287ab6bdd9c4f29da..97281374b22252059fcbf65ff28d426615b2a632 100644 (file)
@@ -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;
     }
 
index 9c03754d58568a04f9a7971d2296ab014c19f054..130de6343f8ec42bac91c7b6114e83ab2a4f854c 100644 (file)
@@ -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 {