Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-04-19 03:13:52 +0400
committerRussell Belfer <rb@github.com>2013-04-19 03:13:52 +0400
commit1af80a676613882b3e04e82874c6e7c8c14b5f49 (patch)
treee90046ac836542aa0646e0b575c9f91d2d04f3d4 /src/iterator.c
parent38fd8121a2a87cc0da405b50f4439ca6578dcff5 (diff)
Fix workdir iterator leak
When attempting to create a workdir iterator for a bare repo, don't leak the iterator structure.
Diffstat (limited to 'src/iterator.c')
-rw-r--r--src/iterator.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/iterator.c b/src/iterator.c
index a72f97eca..ff08c1ce0 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -1252,16 +1252,14 @@ int git_iterator_for_workdir(
const char *end)
{
int error;
- workdir_iterator *wi = git__calloc(1, sizeof(workdir_iterator));
- GITERR_CHECK_ALLOC(wi);
-
- assert(out && repo);
+ workdir_iterator *wi;
- if ((error = git_repository__ensure_not_bare(
- repo, "scan working directory")) < 0)
- return error;
+ if (git_repository__ensure_not_bare(repo, "scan working directory") < 0)
+ return GIT_EBAREREPO;
/* initialize as an fs iterator then do overrides */
+ wi = git__calloc(1, sizeof(workdir_iterator));
+ GITERR_CHECK_ALLOC(wi);
ITERATOR_BASE_INIT((&wi->fi), fs, FS, repo);
wi->fi.base.type = GIT_ITERATOR_TYPE_WORKDIR;