threads / patch / 13949

patchDon't allocate too much memory in quote_ref_url

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

## tl;dr

One message between Jun 14, 2008 and Jun 14, 2008. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Mike Hommey· Jun 14, 2008, 10:02 UTC · lore

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(-)
Show changes to http.c +1 −1
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

← back to recent threads