summaryrefslogtreecommitdiff
path: root/bundle.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-10-03 22:40:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-10-07 17:48:09 (GMT)
commit64045940af0539f15335d7664908e74d1febc439 (patch)
tree3a81be1b9f6a85ddda34c443716155c4ab1bd2b1 /bundle.c
parent80b616d04b8f5a15b5d5587d67baf6e2e28c9f87 (diff)
downloadgit-64045940af0539f15335d7664908e74d1febc439.zip
git-64045940af0539f15335d7664908e74d1febc439.tar.gz
git-64045940af0539f15335d7664908e74d1febc439.tar.bz2
bundle: plug minor memory leak in is_tag_in_date_range()
Free the buffer returned by read_sha1_file() even if no valid tagger line is found. Signed-off-by: Rene Scharfe <l.s.r@web.de> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'bundle.c')
-rw-r--r--bundle.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/bundle.c b/bundle.c
index b708906..643b8b8 100644
--- a/bundle.c
+++ b/bundle.c
@@ -209,26 +209,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,