From: Jeff King <peff@peff•net>
To: git@vger•kernel.org
Cc: Stefan Beller <stefanbeller@gmail•com>
Subject: [PATCH 3/5] transport: fix leaks in refs_from_alternate_cb
Date: Thu, 24 Jul 2014 00:41:30 -0400 [thread overview]
Message-ID: <20140724044130.GC32355@peff.net> (raw)
In-Reply-To: <20140724043940.GA31282@peff.net>
The function starts by creating a copy of the static buffer
returned by real_path, but forgets to free it in the error
code paths. We can solve this by jumping to the cleanup code
that is already there.
Signed-off-by: Jeff King <peff@peff•net>
---
transport.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/transport.c b/transport.c
index 3e42570..297e981 100644
--- a/transport.c
+++ b/transport.c
@@ -1359,11 +1359,11 @@ static int refs_from_alternate_cb(struct alternate_object_database *e,
while (other[len-1] == '/')
other[--len] = '\0';
if (len < 8 || memcmp(other + len - 8, "/objects", 8))
- return 0;
+ goto out;
/* Is this a git repository with refs? */
memcpy(other + len - 8, "/refs", 6);
if (!is_directory(other))
- return 0;
+ goto out;
other[len - 8] = '\0';
remote = remote_get(other);
transport = transport_get(remote, other);
@@ -1372,6 +1372,7 @@ static int refs_from_alternate_cb(struct alternate_object_database *e,
extra = extra->next)
cb->fn(extra, cb->data);
transport_disconnect(transport);
+out:
free(other);
return 0;
}
--
2.0.0.566.gfe3e6b2
next prev parent reply other threads:[~2014-07-24 4:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-24 4:39 [PATCH 0/5] coverity mixed bag Jeff King
2014-07-24 4:40 ` [PATCH 1/5] receive-pack: don't copy "dir" parameter Jeff King
2014-07-24 4:41 ` [PATCH 2/5] free ref string returned by dwim_ref Jeff King
2014-07-24 4:41 ` Jeff King [this message]
2014-07-24 4:42 ` [PATCH 4/5] fix memory leak parsing core.commentchar Jeff King
2014-07-24 4:43 ` [PATCH 5/5] apply: avoid possible bogus pointer Jeff King
2014-07-24 20:33 ` [PATCH 0/5] coverity mixed bag Junio C Hamano
2014-07-29 5:36 ` Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140724044130.GC32355@peff.net \
--to=peff@peff$(echo .)net \
--cc=git@vger$(echo .)kernel.org \
--cc=stefanbeller@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox