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

Re: [PATCH 1/2] builtin/checkout.c: don't leak memory in check_tracking_name

From
Jeff King <peff@peff.net>
Date
Jun 18, 2013, 06:15 UTC
Message-ID
<20130618061500.GF5916@sigill.intra.peff.net>
In-Reply-To
<1371519650-17869-1-git-send-email-bcasey@nvidia.com>
On Mon, Jun 17, 2013 at 06:40:49PM -0700, Brandon Casey wrote:
Show 10 quoted lines
> From: Brandon Casey <drafnel@gmail.com>
> 
> remote_find_tracking() populates the query struct with an allocated
> string in the dst member.  So, we do not need to xstrdup() the string,
> since we can transfer ownership from the query struct (which will go
> out of scope at the end of this function) to our callback struct, but
> we must free the string if it will not be used so we will not leak
> memory.
> 
> Let's do so.

Thanks, looks obviously correct. I wonder if other callers of remote_find_tracking make the same mistake. It looks like check_tracking_branch does. And add_branch_for_removal. and append_ref_to_tracked_list. Yeesh.

-Peff
Previous: Junio C Hamano
Message 5 of 5 in “builtin/checkout.c: don't leak memory in check_tracking_name”
  1. 1/2 builtin/checkout.c: don't leak memory in check_tracking_nameBrandon Casey, Jun 18, 2013
  2. 2/2 t/t9802: explicitly name the upstream branch to use as a baseBrandon Casey, Jun 18, 2013
  3. Pete WyckoffJun 18, 2013
  4. Junio C HamanoJun 18, 2013
  5. Jeff KingJun 18, 2013

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.