Merge branch 'rs/plug-leak-in-bundle'

* rs/plug-leak-in-bundle:
  bundle: plug minor memory leak in is_tag_in_date_range()
This commit is contained in:
Junio C Hamano 2014-10-14 10:50:09 -07:00
commit 0189df3161

View File

@ -210,26 +210,29 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
{ {
unsigned long size; unsigned long size;
enum object_type type; enum object_type type;
char *buf, *line, *lineend; char *buf = NULL, *line, *lineend;
unsigned long date; unsigned long date;
int result = 1;
if (revs->max_age == -1 && revs->min_age == -1) if (revs->max_age == -1 && revs->min_age == -1)
return 1; goto out;
buf = read_sha1_file(tag->sha1, &type, &size); buf = read_sha1_file(tag->sha1, &type, &size);
if (!buf) if (!buf)
return 1; goto out;
line = memmem(buf, size, "\ntagger ", 8); line = memmem(buf, size, "\ntagger ", 8);
if (!line++) if (!line++)
return 1; goto out;
lineend = memchr(line, '\n', buf + size - line); lineend = memchr(line, '\n', buf + size - line);
line = memchr(line, '>', lineend ? lineend - line : buf + size - line); line = memchr(line, '>', lineend ? lineend - line : buf + size - line);
if (!line++) if (!line++)
return 1; goto out;
date = strtoul(line, NULL, 10); date = strtoul(line, NULL, 10);
free(buf); result = (revs->max_age == -1 || revs->max_age < date) &&
return (revs->max_age == -1 || revs->max_age < date) &&
(revs->min_age == -1 || revs->min_age > date); (revs->min_age == -1 || revs->min_age > date);
out:
free(buf);
return result;
} }
int create_bundle(struct bundle_header *header, const char *path, int create_bundle(struct bundle_header *header, const char *path,