diff options
author | Patrick Steinhardt <ps@pks.im> | 2016-08-24 08:28:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-24 08:28:49 +0200 |
commit | c60210d36780a39db669e52d6d592d339c6a2ed3 (patch) | |
tree | d545d08e58a1ac4406aaaafb880dfab6718eafb5 | |
parent | c1b370e9313a13df350974e2237997cc651a5d67 (diff) | |
parent | 7a3f1de500423ed1cdf1d97a273146f2098b672e (diff) | |
download | libgit2-c60210d36780a39db669e52d6d592d339c6a2ed3.tar.gz |
Merge pull request #3904 from stinb/filesystem-iterator-double-free
filesystem_iterator: fixed double free on error
-rw-r--r-- | src/iterator.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/iterator.c b/src/iterator.c index 87e0d53d4..598c69c83 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -1834,6 +1834,9 @@ static int iterator_for_filesystem( iter = git__calloc(1, sizeof(filesystem_iterator)); GITERR_CHECK_ALLOC(iter); + iter->base.type = type; + iter->base.cb = &callbacks; + root_len = strlen(root); iter->root = git__malloc(root_len+2); @@ -1851,9 +1854,6 @@ static int iterator_for_filesystem( if ((error = git_buf_puts(&iter->current_path, iter->root)) < 0) goto on_error; - iter->base.type = type; - iter->base.cb = &callbacks; - if ((error = iterator_init_common(&iter->base, repo, index, options)) < 0) goto on_error; @@ -1877,8 +1877,6 @@ static int iterator_for_filesystem( return 0; on_error: - git__free(iter->root); - git_buf_free(&iter->current_path); git_iterator_free(&iter->base); return error; } |