From 7bfd7c63b638f51579632a29f99ebfaa6833b5e8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 29 Jun 2026 19:03:20 +0200 Subject: [PATCH] fixup! Refuse to follow invalid paths in `.git` files TortoiseGit actually compiles kind of a "libified" version of this, where the `die()` calls are substituted with C++ `throw` constructs. Therefore the (`static`, stays allocated even after returning from the function) `realpath` actually _can_ be reused. Signed-off-by: Johannes Schindelin --- setup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.c b/setup.c index 4567761e6e..fa7a5c1f3e 100644 --- a/setup.c +++ b/setup.c @@ -1047,6 +1047,7 @@ const char *read_gitfile_gently(const char *path, int *return_error_code) } #if (defined _WIN32 || defined __WIN32__) if (is_dir_sep(dir[0]) && is_invalid_dotgit_path(path, dir)) { + strbuf_reset(&realpath); strbuf_add(&realpath, dir, strlen(dir)); path = realpath.buf; goto cleanup_return; @@ -1057,6 +1058,7 @@ const char *read_gitfile_gently(const char *path, int *return_error_code) goto cleanup_return; } + strbuf_reset(&realpath); strbuf_realpath(&realpath, dir, 1); path = realpath.buf;