Code

diff: make sure --output=/bad/path is caught
authorLarry D'Anna <larry@elder-gods.org>
Tue, 16 Feb 2010 04:10:45 +0000 (23:10 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Feb 2010 05:46:01 +0000 (21:46 -0800)
The return value from fopen wasn't being checked.

Signed-off-by: Larry D'Anna <larry@elder-gods.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c

diff --git a/diff.c b/diff.c
index 17a2b4df2922427920d4bb896f173247f93433e4..8d8405aba29a4240f6a68c5fb1e3f0ad15050318 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -2799,6 +2799,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
                ;
        else if (!prefixcmp(arg, "--output=")) {
                options->file = fopen(arg + strlen("--output="), "w");
+               if (!options->file)
+                       die_errno("Could not open '%s'", arg + strlen("--output="));
                options->close_file = 1;
        } else
                return 0;