From: Junio C Hamano Date: Tue, 14 Oct 2014 17:50:09 +0000 (-0700) Subject: Merge branch 'rs/plug-leak-in-bundle' X-Git-Tag: v2.2.0-rc0~48 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0189df3161986643565f12418a8c64edbc42de2e?hp=-c Merge branch 'rs/plug-leak-in-bundle' * rs/plug-leak-in-bundle: bundle: plug minor memory leak in is_tag_in_date_range() --- 0189df3161986643565f12418a8c64edbc42de2e diff --combined bundle.c index 891a3cacda,643b8b8b2e..9a22ab5c02 --- a/bundle.c +++ b/bundle.c @@@ -1,5 -1,4 +1,5 @@@ #include "cache.h" +#include "lockfile.h" #include "bundle.h" #include "object.h" #include "commit.h" @@@ -210,26 -209,29 +210,29 @@@ static int is_tag_in_date_range(struct { 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, @@@ -241,7 -243,7 +244,7 @@@ int i, ref_count = 0; struct strbuf buf = STRBUF_INIT; struct rev_info revs; - struct child_process rls; + struct child_process rls = CHILD_PROCESS_INIT; FILE *rls_fout; bundle_to_stdout = !strcmp(path, "-"); @@@ -259,6 -261,7 +262,6 @@@ init_revisions(&revs, NULL); /* write prerequisites */ - memset(&rls, 0, sizeof(rls)); argv_array_pushl(&rls.args, "rev-list", "--boundary", "--pretty=oneline", NULL); @@@ -417,13 -420,14 +420,13 @@@ int unbundle(struct bundle_header *head { const char *argv_index_pack[] = {"index-pack", "--fix-thin", "--stdin", NULL, NULL}; - struct child_process ip; + struct child_process ip = CHILD_PROCESS_INIT; if (flags & BUNDLE_VERBOSE) argv_index_pack[3] = "-v"; if (verify_bundle(header, 0)) return -1; - memset(&ip, 0, sizeof(ip)); ip.argv = argv_index_pack; ip.in = bundle_fd; ip.no_stdout = 1;