Skip to content

Commit 0189df3

Browse files
committed
Merge branch 'rs/plug-leak-in-bundle'
* rs/plug-leak-in-bundle: bundle: plug minor memory leak in is_tag_in_date_range()
2 parents 145c590 + 6404594 commit 0189df3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

bundle.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,26 +210,29 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
210210
{
211211
unsigned long size;
212212
enum object_type type;
213-
char *buf, *line, *lineend;
213+
char *buf = NULL, *line, *lineend;
214214
unsigned long date;
215+
int result = 1;
215216

216217
if (revs->max_age == -1 && revs->min_age == -1)
217-
return 1;
218+
goto out;
218219

219220
buf = read_sha1_file(tag->sha1, &type, &size);
220221
if (!buf)
221-
return 1;
222+
goto out;
222223
line = memmem(buf, size, "\ntagger ", 8);
223224
if (!line++)
224-
return 1;
225+
goto out;
225226
lineend = memchr(line, '\n', buf + size - line);
226227
line = memchr(line, '>', lineend ? lineend - line : buf + size - line);
227228
if (!line++)
228-
return 1;
229+
goto out;
229230
date = strtoul(line, NULL, 10);
230-
free(buf);
231-
return (revs->max_age == -1 || revs->max_age < date) &&
231+
result = (revs->max_age == -1 || revs->max_age < date) &&
232232
(revs->min_age == -1 || revs->min_age > date);
233+
out:
234+
free(buf);
235+
return result;
233236
}
234237

235238
int create_bundle(struct bundle_header *header, const char *path,

0 commit comments

Comments
 (0)