From: Jeff King Date: Tue, 18 Jun 2013 06:15:01 GMT Subject: Re: [PATCH 1/2] builtin/checkout.c: don't leak memory in check_tracking_name 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: > From: Brandon Casey > > 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