git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] fetch: fix wrong evaluation order in URL trailing-slash trimming

From
CGcui via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 25, 2026, 02:00 UTC
Message-ID
<pull.2211.git.git.1771984857879.gitgitgadget@gmail.com>
From: cuiweixie <cuiweixie@gmail.com>
if i == -1, url[i] will be UB.
Signed-off-by: cuiweixie <cuiweixie@gmail.com>
---
    fetch: fix wrong evaluation order in URL trailing-slash trimming
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2211%2Fcuiweixie%2Fbugfix-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2211/cuiweixie/bugfix-v1
Pull-Request: https://github.com/git/git/pull/2211
 builtin/fetch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index a3bc7e9380..306138c6e5 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -722,7 +722,7 @@ static void display_state_init(struct display_state *display_state, struct ref *
 		display_state->url = xstrdup("foreign");
 
 	display_state->url_len = strlen(display_state->url);
-	for (i = display_state->url_len - 1; display_state->url[i] == '/' && 0 <= i; i--)
+	for (i = display_state->url_len - 1; 0 <= i && display_state->url[i] == '/'; i--)
 		;
 	display_state->url_len = i + 1;
 	if (4 < i && !strncmp(".git", display_state->url + i - 3, 4))

base-commit: 7c02d39fc2ed2702223c7674f73150d9a7e61ba4
-- 
gitgitgadget
Next: Jeff King
Message 1 of 3 in “fetch: fix wrong evaluation order in URL trailing-slash trimming”
  1. fetch: fix wrong evaluation order in URL trailing-slash trimmingcui via GitGitGadget, Feb 25, 2026
  2. Jeff KingFeb 25, 2026
  3. Junio C HamanoFeb 25, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.