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

Re: [PATCH] bundle: plug minor memory leak in is_tag_in_date_range()

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 3, 2014, 23:40 UTC
Message-ID
<20141003234045.GU1175@google.com>
In-Reply-To
<542F25D8.1000900@web.de>
René Scharfe wrote:
Show 5 quoted lines
> --- 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;
 }
 
Previous: René Scharfe
Message 2 of 2 in “bundle: plug minor memory leak in is_tag_in_date_range()”
  1. bundle: plug minor memory leak in is_tag_in_date_range()René Scharfe, Oct 3, 2014
  2. Jonathan NiederOct 3, 2014

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.