Commit 7a3f1de5 by Jason Haslam

filesystem_iterator: fixed double free on error

parent c1b370e9
...@@ -1834,6 +1834,9 @@ static int iterator_for_filesystem( ...@@ -1834,6 +1834,9 @@ static int iterator_for_filesystem(
iter = git__calloc(1, sizeof(filesystem_iterator)); iter = git__calloc(1, sizeof(filesystem_iterator));
GITERR_CHECK_ALLOC(iter); GITERR_CHECK_ALLOC(iter);
iter->base.type = type;
iter->base.cb = &callbacks;
root_len = strlen(root); root_len = strlen(root);
iter->root = git__malloc(root_len+2); iter->root = git__malloc(root_len+2);
...@@ -1851,9 +1854,6 @@ static int iterator_for_filesystem( ...@@ -1851,9 +1854,6 @@ static int iterator_for_filesystem(
if ((error = git_buf_puts(&iter->current_path, iter->root)) < 0) if ((error = git_buf_puts(&iter->current_path, iter->root)) < 0)
goto on_error; goto on_error;
iter->base.type = type;
iter->base.cb = &callbacks;
if ((error = iterator_init_common(&iter->base, repo, index, options)) < 0) if ((error = iterator_init_common(&iter->base, repo, index, options)) < 0)
goto on_error; goto on_error;
...@@ -1877,8 +1877,6 @@ static int iterator_for_filesystem( ...@@ -1877,8 +1877,6 @@ static int iterator_for_filesystem(
return 0; return 0;
on_error: on_error:
git__free(iter->root);
git_buf_free(&iter->current_path);
git_iterator_free(&iter->base); git_iterator_free(&iter->base);
return error; return error;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment