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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>

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;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]