Re: [PATCH] Fix minor memory leak in init-db
- From
Ammon Riley <ammon.riley@gmail.com>
- Date
- May 17, 2009, 04:07 UTC
- Message-ID
- <cd3664ac0905162107t7ebca943p1722685a8484f08e@mail.gmail.com>
- In-Reply-To
- <7vzldclt33.fsf@alter.siamese.dyndns.org>
On Sat, May 16, 2009 at 12:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 7 quoted lines
> Ammon Riley <ammon.riley@gmail.com> writes: > >> There was an xmalloc() for path, but I didn't see a corresponding free(). >> Does it happen somewhere else that I'm not expecting? > > It implicitly happens in exit() in git.c:handle_internal_command() > after cmd_init_db() returns the control to it.
Ah. Naturally. :)
So if I were to write a long-lived application (such as a custom UI) that links to libgit, and bypasses those functions to call init_db() (and other functions) directly, all those implicit free-on-exit() turn into memory leaks.
Cheers, Ammon