Skip to content

Commit 9179380

Browse files
committed
Merge branch 'mt/dir-iterator-updates'
Leakfix. * mt/dir-iterator-updates: test-dir-iterator: use path argument directly dir-iterator: release strbuf after use
2 parents 203cf46 + 7df3bd4 commit 9179380

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

refs/files-backend.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2151,8 +2151,10 @@ static struct ref_iterator *reflog_iterator_begin(struct ref_store *ref_store,
21512151
strbuf_addf(&sb, "%s/logs", gitdir);
21522152

21532153
diter = dir_iterator_begin(sb.buf, 0);
2154-
if(!diter)
2154+
if (!diter) {
2155+
strbuf_release(&sb);
21552156
return empty_ref_iterator_begin();
2157+
}
21562158

21572159
iter = xcalloc(1, sizeof(*iter));
21582160
ref_iterator = &iter->base;

t/helper/test-dir-iterator.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ static const char *error_name(int error_number)
1919
*/
2020
int cmd__dir_iterator(int argc, const char **argv)
2121
{
22-
struct strbuf path = STRBUF_INIT;
2322
struct dir_iterator *diter;
2423
unsigned int flags = 0;
2524
int iter_status;
@@ -36,8 +35,7 @@ int cmd__dir_iterator(int argc, const char **argv)
3635
if (!*argv || argc != 1)
3736
die("dir-iterator needs exactly one non-option argument");
3837

39-
strbuf_add(&path, *argv, strlen(*argv));
40-
diter = dir_iterator_begin(path.buf, flags);
38+
diter = dir_iterator_begin(*argv, flags);
4139

4240
if (!diter) {
4341
printf("dir_iterator_begin failure: %s\n", error_name(errno));

0 commit comments

Comments
 (0)