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
Ccuiweixie <cuiweixie@gmail.com>
Date
Feb 23, 2026, 10:07 UTC
Message-ID
<20260223100728.79928-1-cuiweixie@gmail.com>
if i == -1, url[i] will be UB.
Signed-off-by: cuiweixie <cuiweixie@gmail.com>
---
 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))
-- 
2.39.5 (Apple Git-154)
Message 1 of 1 in “fetch: fix wrong evaluation order in URL trailing-slash trimming”
  1. fetch: fix wrong evaluation order in URL trailing-slash trimmingcuiweixie, Feb 23, 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.