Skip to content

Commit

Permalink
Merge branch 'rs/plug-leak-in-bundle'
Browse files Browse the repository at this point in the history
* rs/plug-leak-in-bundle:
  bundle: plug minor memory leak in is_tag_in_date_range()
  • Loading branch information
Junio C Hamano committed Oct 14, 2014
2 parents 145c590 + 6404594 commit 0189df3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,26 +210,29 @@ 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;

if (revs->max_age == -1 && revs->min_age == -1)
return 1;
goto out;

buf = read_sha1_file(tag->sha1, &type, &size);
if (!buf)
return 1;
goto out;
line = memmem(buf, size, "\ntagger ", 8);
if (!line++)
return 1;
goto out;
lineend = memchr(line, '\n', buf + size - line);
line = memchr(line, '>', lineend ? lineend - line : buf + size - line);
if (!line++)
return 1;
goto out;
date = strtoul(line, NULL, 10);
free(buf);
return (revs->max_age == -1 || revs->max_age < date) &&
result = (revs->max_age == -1 || revs->max_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,
Expand Down

0 comments on commit 0189df3

Please sign in to comment.