[PATCH 1/2] bugfix: segfault on git diff --output=/bad/path
The return value from fopen wasn't being checked.
Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
diff.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/diff.c b/diff.c
index 381cc8d..68def6c 100644
--- a/diff.c
+++ b/diff.c
@@ -2893,6 +2893,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;
--
1.7.0.rc2.40.g7d8aa