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>

René Scharfe committed Oct 4, 2014 at 00:40 UTC 64045940af0539f15335d7664908e74d1febc439
1 file changed +10 -7
bundle.c
+10 -7
@@ -209,26 +209,29 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
209 {
210 unsigned long size;
211 enum object_type type;
212 - char *buf, *line, *lineend;
212 + char *buf = NULL, *line, *lineend;
213 unsigned long date;
214 + int result = 1;
215
216 if (revs->max_age == -1 && revs->min_age == -1)
216 - return 1;
217 + goto out;
218
219 buf = read_sha1_file(tag->sha1, &type, &size);
220 if (!buf)
220 - return 1;
221 + goto out;
222 line = memmem(buf, size, "\ntagger ", 8);
223 if (!line++)
223 - return 1;
224 + goto out;
225 lineend = memchr(line, '\n', buf + size - line);
226 line = memchr(line, '>', lineend ? lineend - line : buf + size - line);
227 if (!line++)
227 - return 1;
228 + goto out;
229 date = strtoul(line, NULL, 10);
229 - free(buf);
230 - return (revs->max_age == -1 || revs->max_age < date) &&
230 + result = (revs->max_age == -1 || revs->max_age < date) &&
231 (revs->min_age == -1 || revs->min_age > date);
232 +out:
233 + free(buf);
234 + return result;
235 }
236
237 int create_bundle(struct bundle_header *header, const char *path,