diff options
| author | Ben Straub <bstraub@github.com> | 2012-05-31 13:42:58 -0700 |
|---|---|---|
| committer | Ben Straub <bstraub@github.com> | 2012-05-31 13:42:58 -0700 |
| commit | b183a92fc2f030acf4c8e0cd76a5259d8f65669a (patch) | |
| tree | 5d2406aa1764aa85b8f77534beb316385b4619c2 /src/revparse.c | |
| parent | 244d2f6b80161978cce5bacc3ac6e663b530bb65 (diff) | |
| download | libgit2-b183a92fc2f030acf4c8e0cd76a5259d8f65669a.tar.gz | |
Rev-parse: Plug memory leaks.
Diffstat (limited to 'src/revparse.c')
| -rw-r--r-- | src/revparse.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/revparse.c b/src/revparse.c index 1e78d7623..60e819c00 100644 --- a/src/revparse.c +++ b/src/revparse.c @@ -541,6 +541,7 @@ static const git_tree_entry* git_tree_entry_bypath(git_tree *tree, git_repositor { char *str = git__strdup(path); char *tok; + void *alloc = str; git_tree *tree2 = tree; const git_tree_entry *entry; @@ -549,11 +550,13 @@ static const git_tree_entry* git_tree_entry_bypath(git_tree *tree, git_repositor if (tree2 != tree) git_tree_free(tree2); if (entry_is_tree(entry)) { if (git_tree_lookup(&tree2, repo, &entry->oid) < 0) { + free(alloc); return NULL; } } } + free(alloc); return entry; } @@ -573,6 +576,7 @@ static int handle_colon_syntax(git_object **out, /* Find the blob at the given path. */ entry = git_tree_entry_bypath(tree, repo, path); + git_tree_free(tree); return git_tree_entry_2object(out, repo, entry); } |
