diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-10-14 10:50:09 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-10-14 10:50:10 -0700 |
commit | 0189df3161986643565f12418a8c64edbc42de2e (patch) | |
tree | 45a9c200877089e7b5ea7f03788e5f5531dcb528 /bundle.c | |
parent | 145c590df8131abe510adde677eb3121cf52d31e (diff) | |
parent | 64045940af0539f15335d7664908e74d1febc439 (diff) | |
download | git-0189df3161986643565f12418a8c64edbc42de2e.tar.gz |
Merge branch 'rs/plug-leak-in-bundle'
* rs/plug-leak-in-bundle:
bundle: plug minor memory leak in is_tag_in_date_range()
Diffstat (limited to 'bundle.c')
-rw-r--r-- | bundle.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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, |