diff options
author | Carl Worth <cworth@cworth.org> | 2009-10-26 09:20:32 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2009-10-26 13:36:40 -0700 |
commit | 46ba33b1159fb48b8360ddae72492cc3162dc999 (patch) | |
tree | ad9a256ad17f0cbb8d784c446eaf3be3001ab1da /notmuch.c | |
parent | 789495919aaaba47040faded49276b217068c6af (diff) |
notmuch restore: Fix leak of FILE* object.
Apparently, I didn't copy enough of the "notmuch dump" implementation
since it didn't have a similar leak.
Diffstat (limited to 'notmuch.c')
-rw-r--r-- | notmuch.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -668,7 +668,7 @@ show_command (unused (int argc), unused (char *argv[])) static int dump_command (int argc, char *argv[]) { - FILE *output; + FILE *output = NULL; notmuch_database_t *notmuch = NULL; notmuch_query_t *query; notmuch_message_results_t *results; @@ -735,7 +735,7 @@ dump_command (int argc, char *argv[]) DONE: if (notmuch) notmuch_database_close (notmuch); - if (output != stdout) + if (output && output != stdout) fclose (output); return ret; @@ -744,7 +744,7 @@ dump_command (int argc, char *argv[]) static int restore_command (int argc, char *argv[]) { - FILE *input; + FILE *input = NULL; notmuch_database_t *notmuch = NULL; char *line = NULL; size_t line_size; @@ -845,6 +845,8 @@ restore_command (int argc, char *argv[]) free (line); if (notmuch) notmuch_database_close (notmuch); + if (input && input != stdin) + fclose (input); return ret; } |