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

[PATCHv3 1/6] shallow: fix a memleak

From
Stefan Beller <sbeller@google.com>
Date
Mar 31, 2015, 01:22 UTC
Message-ID
<1427764931-27745-2-git-send-email-sbeller@google.com>
In-Reply-To
<1427764931-27745-1-git-send-email-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 shallow.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/shallow.c b/shallow.c
index d8bf40a..11d5c4e 100644
--- a/shallow.c
+++ b/shallow.c
@@ -412,11 +412,12 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
 	struct commit_list *head = NULL;
 	int bitmap_nr = (info->nr_bits + 31) / 32;
 	int bitmap_size = bitmap_nr * sizeof(uint32_t);
-	uint32_t *tmp = xmalloc(bitmap_size); /* to be freed before return */
-	uint32_t *bitmap = paint_alloc(info);
+	uint32_t *tmp, *bitmap;
 	struct commit *c = lookup_commit_reference_gently(sha1, 1);
 	if (!c)
 		return;
+	tmp = xmalloc(bitmap_size); /* to be freed before return */
+	bitmap = paint_alloc(info);
 	memset(bitmap, 0, bitmap_size);
 	bitmap[id / 32] |= (1 << (id % 32));
 	commit_list_insert(c, &head);
-- 
2.3.0.81.gc37f363
Previous: Stefan BellerNext: Eric Sunshine
Message 2 of 16 in “[PATCHv3 0/6] Memory leaks once again”
  1. Stefan BellerMar 31, 2015
  2. 1/6 shallow: fix a memleakStefan Beller, Mar 31, 2015
  3. Eric SunshineMar 31, 2015
  4. 2/6 line-log.c: fix a memleakStefan Beller, Mar 31, 2015
  5. 3/6 line-log.c: fix a memleakStefan Beller, Mar 31, 2015
  6. Torsten BögershausenMar 31, 2015
  7. Junio C HamanoMar 31, 2015
  8. Stefan BellerMar 31, 2015
  9. Junio C HamanoMar 31, 2015
  10. 4/6 wt-status.c: fix a memleakStefan Beller, Mar 31, 2015
  11. 5/6 pack-bitmap.c: fix a memleakStefan Beller, Mar 31, 2015
  12. Jeff KingMar 31, 2015
  13. 6/6 entry.c: fix a memleakStefan Beller, Mar 31, 2015
  14. Junio C HamanoMar 31, 2015
  15. John KeepingMar 31, 2015
  16. Junio C HamanoMar 31, 2015

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.