diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2017-10-09 14:57:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-09 14:57:33 +0100 |
| commit | 9840dad26706d5c9d9dcfb2de9251a7f05790ebf (patch) | |
| tree | e9a586b631f63d7fbf4d93803ae5a6f79345fccf /src | |
| parent | fb11544b589cea1d1d490c451704e6328a882033 (diff) | |
| parent | 7cb705cbf7749ba32f9163599fa056b5f4f0ad18 (diff) | |
| download | libgit2-9840dad26706d5c9d9dcfb2de9251a7f05790ebf.tar.gz | |
Merge pull request #4368 from pks-t/pks/smart-negotiate-revwalk-memleak
transports: smart: fix memory leak when skipping symbolic refs
Diffstat (limited to 'src')
| -rw-r--r-- | src/transports/smart_protocol.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c index d51238f12..aecfece0a 100644 --- a/src/transports/smart_protocol.c +++ b/src/transports/smart_protocol.c @@ -273,7 +273,7 @@ static int fetch_setup_walk(git_revwalk **out, git_repository *repo) git_revwalk *walk = NULL; git_strarray refs; unsigned int i; - git_reference *ref; + git_reference *ref = NULL; int error; if ((error = git_reference_list(&refs, repo)) < 0) @@ -285,6 +285,9 @@ static int fetch_setup_walk(git_revwalk **out, git_repository *repo) git_revwalk_sorting(walk, GIT_SORT_TIME); for (i = 0; i < refs.count; ++i) { + git_reference_free(ref); + ref = NULL; + /* No tags */ if (!git__prefixcmp(refs.strings[i], GIT_REFS_TAGS_DIR)) continue; @@ -297,16 +300,13 @@ static int fetch_setup_walk(git_revwalk **out, git_repository *repo) if ((error = git_revwalk_push(walk, git_reference_target(ref))) < 0) goto on_error; - - git_reference_free(ref); } - git_strarray_free(&refs); *out = walk; - return 0; on_error: - git_revwalk_free(walk); + if (error) + git_revwalk_free(walk); git_reference_free(ref); git_strarray_free(&refs); return error; |
