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

[PATCH 11/15] builtin/check-attr: fix a memleak

From
Stefan Beller <sbeller@google.com>
Date
Mar 21, 2015, 00:28 UTC
Message-ID
<1426897692-18322-12-git-send-email-sbeller@google.com>
In-Reply-To
<1426897692-18322-1-git-send-email-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
Notes:
    I do not quite recall a discussion about such fixes
    when I started doing these fixes like 2 years ago.
    
    As this is a main function of a subcommand the freed
    memory is likely to have no impact as the process
    is done soon, so then it gets freed by the OS which
    is likey to be faster as the OS frees the whole pages
    of the process. Also there is no expected memory
    shortage as the process is going to be done soon
    as opposed to fixing mem leaks early in the process.
    
    An upside of fixes like this one is however to make
    code analysis tools produce less noise, so narrowing
    down the *real* issue may be easier.
    
    I wonder if we could have a 'weak' free which does
    nothing if git is compiled regularly and actually
    frees the memory if it is build with a flag to tell
    it to do so. This would help finding the real issues
    as the noise goes down and it would still be 'fast'
    as it could be when compiled for productive use.
    
    On the other hand I don't like to have another
    'invented here again' systemcall-ish function as
    it would clutter the code and you'd have to remember
    to use that weak free.
    
    I dunno.
 builtin/check-attr.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 21d2bed..fa96356 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -182,5 +182,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
 			check_attr(prefix, cnt, check, argv[i]);
 		maybe_flush_or_die(stdout, "attribute to stdout");
 	}
+
+	free(check);
 	return 0;
 }
-- 
2.3.0.81.gc37f363
Previous: Stefan BellerNext: Junio C Hamano
Message 38 of 44 in “Fixing memory leaks”
  1. 00/15 Fixing memory leaksStefan Beller, Mar 21, 2015
  2. 01/15 read-cache: fix memleakStefan Beller, Mar 21, 2015
  3. Junio C HamanoMar 21, 2015
  4. Stefan BellerMar 23, 2015
  5. 1/2 read-cache: fix memleakStefan Beller, Mar 23, 2015
  6. 2/2 read-cache.c: fix a memleak in add_to_indexStefan Beller, Mar 23, 2015
  7. Junio C HamanoMar 23, 2015
  8. Junio C HamanoMar 23, 2015
  9. 02/15 read-cache: Improve readabilityStefan Beller, Mar 21, 2015
  10. Junio C HamanoMar 21, 2015
  11. Stefan BellerMar 21, 2015
  12. Junio C HamanoMar 22, 2015
  13. 03/15 read-cache: free cache entry in add_to_index in case of early returnStefan Beller, Mar 21, 2015
  14. Junio C HamanoMar 21, 2015
  15. Stefan BellerMar 21, 2015
  16. Junio C HamanoMar 22, 2015
  17. 04/15 update-index: fix a memleakStefan Beller, Mar 21, 2015
  18. Junio C HamanoMar 21, 2015
  19. update-index: Don't copy memory aroundStefan Beller, Mar 23, 2015
  20. Junio C HamanoMar 23, 2015
  21. 05/15 builtin/apply.c: fix a memleakStefan Beller, Mar 21, 2015
  22. Junio C HamanoMar 21, 2015
  23. builtin/apply.c: fix a memleak (Fixup, squashable)Stefan Beller, Mar 23, 2015
  24. Junio C HamanoMar 23, 2015
  25. 06/15 merge-blobs.c: Fix a memleakStefan Beller, Mar 21, 2015
  26. 07/15 merge-recursive: fix memleaksStefan Beller, Mar 21, 2015
  27. Junio C HamanoMar 21, 2015
  28. 08/15 http-push: Remove unneeded cleanupStefan Beller, Mar 21, 2015
  29. 09/15 http: release the memory of a http pack request as wellStefan Beller, Mar 21, 2015
  30. Junio C HamanoMar 22, 2015
  31. Stefan BellerMar 24, 2015
  32. Junio C HamanoMar 24, 2015
  33. 10/15 commit.c: fix a memory leakStefan Beller, Mar 21, 2015
  34. Junio C HamanoMar 21, 2015
  35. Duy NguyenMar 24, 2015
  36. Re* [PATCH 10/15] commit.c: fix a memory leakJunio C Hamano, Mar 24, 2015
  37. Stefan BellerMar 24, 2015
  38. 11/15 builtin/check-attr: fix a memleakStefan Beller, Mar 21, 2015
  39. Junio C HamanoMar 21, 2015
  40. 12/15 builtin/merge-base: fix memleakStefan Beller, Mar 21, 2015
  41. 13/15 builtin/unpack-file: fix a memleakStefan Beller, Mar 21, 2015
  42. 14/15 builtin/cat-file: free memleakStefan Beller, Mar 21, 2015
  43. 15/15 ls-files: fix a memleakStefan Beller, Mar 21, 2015
  44. Junio C HamanoMar 21, 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.