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

Re: Git crashes on pull

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Sep 18, 2009, 13:39 UTC
Message-ID
<20090918213948.4bb65f4e.rctay89@gmail.com>
In-Reply-To
<7vzl8v4y5g.fsf@alter.siamese.dyndns.org>
Hi,
On Wed, Sep 16, 2009 at 6:54 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 7 quoted lines
> Thanks.
>
> The sad part of the story was that this regression was introduced by a
> change to work around recent breakage observed when fetching from the http
> server github runs, and it was the primary purpose of pushing 1.6.4.3 out.
>
> Now we need to cut a 1.6.4.4 with this fix-on-fix soon, like tomorrow.
sorry for all the trouble caused.
Junio, do you think moving out the free() would be a better option? Setting it to NULL just so we can free() is rather contrived, I feel.
-- >8 --
Subject: [PATCH] http.c: move free() out of cleanup block

Instead of initializing a variable (url) just so we can do a free() on it, as in b202514 (http.c: avoid freeing an uninitialized pointer), we move the free() out of cleanup block.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 http.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/http.c b/http.c
index 23b2a19..a67f62e 100644
--- a/http.c
+++ b/http.c
@@ -866,7 +866,7 @@ static int fetch_pack_index(unsigned char *sha1, const char *base_url)
 	int ret = 0;
 	char *hex = xstrdup(sha1_to_hex(sha1));
 	char *filename;
-	char *url = NULL;
+	char *url;
 	struct strbuf buf = STRBUF_INIT;

 	if (has_pack_index(sha1)) {
@@ -885,9 +885,9 @@ static int fetch_pack_index(unsigned char *sha1, const char *base_url)
 	if (http_get_file(url, filename, 0) != HTTP_OK)
 		ret = error("Unable to get pack index %s\n", url);

+	free(url);
 cleanup:
 	free(hex);
-	free(url);
 	return ret;
 }

--
1.6.4.2
Previous: Michael Wookey
Message 6 of 6 in “Git crashes on pull”
  1. Guido OstkampSep 15, 2009
  2. Junio C HamanoSep 15, 2009
  3. Guido OstkampSep 15, 2009
  4. Junio C HamanoSep 15, 2009
  5. Michael WookeySep 15, 2009
  6. Tay Ray ChuanSep 18, 2009

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.