From 2fefc8d563e04f219ef4815d7530579856eaeee6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 12 Jun 2010 18:05:17 +0200 Subject: [PATCH] Fix unchecked chdir() return value Signed-off-by: Johannes Schindelin --- builtin/grep.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/grep.c b/builtin/grep.c index f6657afed7..a5373a473b 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -576,8 +576,9 @@ static void run_pager(struct grep_opt *opt, const char *prefix) argv[i] = path_list->items[i].string; argv[path_list->nr] = NULL; - if (prefix) - chdir(prefix); + if (prefix && chdir(prefix)) + die("Could not chdir(%s)", prefix); + execvp(argv[0], argv); error("Could not run pager %s: %s", argv[0], strerror(errno)); }