summaryrefslogtreecommitdiff
path: root/diff-no-index.c
diff options
context:
space:
mode:
authorClemens Buchacher <drizzd@aon.at>2010-05-22 14:21:27 +0200
committerJunio C Hamano <gitster@pobox.com>2010-05-25 09:28:51 -0700
commit4e1f87959c76455f0092a7c82aee78df60533ae5 (patch)
treef8e943d08b281639ee0b1c4de4bc33c0d4d417d5 /diff-no-index.c
parentc8b296450e5148c576697ea4709072b7855aacd5 (diff)
downloadgit-4e1f87959c76455f0092a7c82aee78df60533ae5.tar.gz
test get_git_work_tree() return value for NULL
If we are in a git directory, get_git_work_tree() can return NULL. While trying to determine whether or not the given paths are outside the work tree, the following command would read from it anyways and trigger a segmentation fault. git diff / / Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-no-index.c')
-rw-r--r--diff-no-index.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/diff-no-index.c b/diff-no-index.c
index aae8e7accc..4cd9dacbe8 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -150,16 +150,14 @@ static int queue_diff(struct diff_options *o,
static int path_outside_repo(const char *path)
{
- /*
- * We have already done setup_git_directory_gently() so we
- * know we are inside a git work tree already.
- */
const char *work_tree;
size_t len;
if (!is_absolute_path(path))
return 0;
work_tree = get_git_work_tree();
+ if (!work_tree)
+ return 1;
len = strlen(work_tree);
if (strncmp(path, work_tree, len) ||
(path[len] != '\0' && path[len] != '/'))