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

[PATCH] Don't allocate too much memory in quote_ref_url

From
Mike Hommey <mh@glandium.org>
Date
Jun 14, 2008, 10:02 UTC
Message-ID
<1213437742-5751-1-git-send-email-mh@glandium.org>

In c13b263, http_fetch_ref got "refs/" included in the ref passed to it, which, incidentally, makes the allocation in quote_ref_url too big, now. ---

I noticed this when rebasing some of my private branches onto current master. I had a commit similar to c13b263 that ended up conflicting, and after conflict resolving, this is all that was left, which is an obvious change that was lacking there.

 http.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/http.c b/http.c
index bc14bdb..9b6d5ed 100644
--- a/http.c
+++ b/http.c
@@ -583,7 +583,7 @@ static char *quote_ref_url(const char *base, const char *ref)
 	int len, baselen, ch;
 
 	baselen = strlen(base);
-	len = baselen + 7; /* "/refs/" + NUL */
+	len = baselen + 2;
 	for (cp = ref; (ch = *cp) != 0; cp++, len++)
 		if (needs_quote(ch))
 			len += 2; /* extra two hex plus replacement % */
-- 
1.5.5.4
Message 1 of 1 in “Don't allocate too much memory in quote_ref_url”
  1. Don't allocate too much memory in quote_ref_urlMike Hommey, Jun 14, 2008

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.