Thread (2 messages) flat view 2 messages, 1 author, 2016-06-15
DORMANTno replies

[PATCH 1/2] bugfix: segfault on git diff --output=/bad/path

From: Larry D'Anna <hidden>
Date: 2016-06-15 22:48:17
Subsystem: the rest · Maintainer: Linus Torvalds

The return value from fopen wasn't being checked.

Signed-off-by: Larry D'Anna <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help