All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] bundle: plug minor memory leak in is_tag_in_date_range()
Date: Fri, 3 Oct 2014 16:40:45 -0700	[thread overview]
Message-ID: <20141003234045.GU1175@google.com> (raw)
In-Reply-To: <542F25D8.1000900@web.de>

René Scharfe wrote:

> --- a/bundle.c
> +++ b/bundle.c
> @@ -211,24 +211,28 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
>  	enum object_type type;
>  	char *buf, *line, *lineend;

If buf is initialized to NULL, there is no need for separate out and
out_free labels.

With or without such a change,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

diff --git i/bundle.c w/bundle.c
index 4158e11..101cde0 100644
--- i/bundle.c
+++ w/bundle.c
@@ -209,7 +209,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
 {
 	unsigned long size;
 	enum object_type type;
-	char *buf, *line, *lineend;
+	char *buf = NULL, *line, *lineend;
 	unsigned long date;
 	int result = 1;
 
@@ -221,17 +221,16 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
 		goto out;
 	line = memmem(buf, size, "\ntagger ", 8);
 	if (!line++)
-		goto out_free;
+		goto out;
 	lineend = memchr(line, '\n', buf + size - line);
 	line = memchr(line, '>', lineend ? lineend - line : buf + size - line);
 	if (!line++)
-		goto out_free;
+		goto out;
 	date = strtoul(line, NULL, 10);
 	result = (revs->max_age == -1 || revs->max_age < date) &&
 		(revs->min_age == -1 || revs->min_age > date);
-out_free:
-	free(buf);
 out:
+	free(buf);
 	return result;
 }
 

      reply	other threads:[~2014-10-03 23:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03 22:40 [PATCH] bundle: plug minor memory leak in is_tag_in_date_range() René Scharfe
2014-10-03 23:40 ` Jonathan Nieder [this message]

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=20141003234045.GU1175@google.com \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.