Merge branch 'mt/dir-iterator-updates'
authorJunio C Hamano <gitster@pobox.com>
Fri, 9 Aug 2019 17:13:14 +0000 (10:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Aug 2019 17:13:14 +0000 (10:13 -0700)
Leakfix.

* mt/dir-iterator-updates:
test-dir-iterator: use path argument directly
dir-iterator: release strbuf after use

refs/files-backend.c
t/helper/test-dir-iterator.c
index b1f8f53a098da3525fdff5011b93f39138df3df2..d60767ab739f0e20e45c700368f7f9f24a52c3f8 100644 (file)
@@ -2151,8 +2151,10 @@ static struct ref_iterator *reflog_iterator_begin(struct ref_store *ref_store,
        strbuf_addf(&sb, "%s/logs", gitdir);
 
        diter = dir_iterator_begin(sb.buf, 0);
-       if(!diter)
+       if (!diter) {
+               strbuf_release(&sb);
                return empty_ref_iterator_begin();
+       }
 
        iter = xcalloc(1, sizeof(*iter));
        ref_iterator = &iter->base;
index c7c30664dad2a027c4cf6b0bac7ecb78080cbcf1..659b6bfa81df6d0bcffb8d0a975492d54d79d6bc 100644 (file)
@@ -19,7 +19,6 @@ static const char *error_name(int error_number)
  */
 int cmd__dir_iterator(int argc, const char **argv)
 {
-       struct strbuf path = STRBUF_INIT;
        struct dir_iterator *diter;
        unsigned int flags = 0;
        int iter_status;
@@ -36,8 +35,7 @@ int cmd__dir_iterator(int argc, const char **argv)
        if (!*argv || argc != 1)
                die("dir-iterator needs exactly one non-option argument");
 
-       strbuf_add(&path, *argv, strlen(*argv));
-       diter = dir_iterator_begin(path.buf, flags);
+       diter = dir_iterator_begin(*argv, flags);
 
        if (!diter) {
                printf("dir_iterator_begin failure: %s\n", error_name(errno));