Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7a3f1de

Browse files
committed
filesystem_iterator: fixed double free on error
1 parent c1b370e commit 7a3f1de

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/iterator.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,9 @@ static int iterator_for_filesystem(
18341834
iter = git__calloc(1, sizeof(filesystem_iterator));
18351835
GITERR_CHECK_ALLOC(iter);
18361836

1837+
iter->base.type = type;
1838+
iter->base.cb = &callbacks;
1839+
18371840
root_len = strlen(root);
18381841

18391842
iter->root = git__malloc(root_len+2);
@@ -1851,9 +1854,6 @@ static int iterator_for_filesystem(
18511854
if ((error = git_buf_puts(&iter->current_path, iter->root)) < 0)
18521855
goto on_error;
18531856

1854-
iter->base.type = type;
1855-
iter->base.cb = &callbacks;
1856-
18571857
if ((error = iterator_init_common(&iter->base, repo, index, options)) < 0)
18581858
goto on_error;
18591859

@@ -1877,8 +1877,6 @@ static int iterator_for_filesystem(
18771877
return 0;
18781878

18791879
on_error:
1880-
git__free(iter->root);
1881-
git_buf_free(&iter->current_path);
18821880
git_iterator_free(&iter->base);
18831881
return error;
18841882
}

0 commit comments

Comments
 (0)