Commit 8e8b6b01 by Carlos Martín Nieto

Clean up valgrind warnings

parent 2ec83ff0
...@@ -334,6 +334,7 @@ static int config_get_multivar( ...@@ -334,6 +334,7 @@ static int config_get_multivar(
var = var->next; var = var->next;
} while (var != NULL); } while (var != NULL);
regfree(&regex);
} else { } else {
/* no regex; go through all the variables */ /* no regex; go through all the variables */
do { do {
......
...@@ -772,7 +772,7 @@ static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_ ...@@ -772,7 +772,7 @@ static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_
static int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const void *data, size_t len, git_otype type) static int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const void *data, size_t len, git_otype type)
{ {
int error, header_len; int error = 0, header_len;
git_buf final_path = GIT_BUF_INIT; git_buf final_path = GIT_BUF_INIT;
char header[64]; char header[64];
git_filebuf fbuf = GIT_FILEBUF_INIT; git_filebuf fbuf = GIT_FILEBUF_INIT;
......
...@@ -43,6 +43,8 @@ static int resolve_head_to_tree(git_tree **tree, git_repository *repo) ...@@ -43,6 +43,8 @@ static int resolve_head_to_tree(git_tree **tree, git_repository *repo)
if (git_object_lookup(&obj, repo, git_reference_oid(head), GIT_OBJ_ANY) < 0) if (git_object_lookup(&obj, repo, git_reference_oid(head), GIT_OBJ_ANY) < 0)
goto fail; goto fail;
git_reference_free(head);
switch (git_object_type(obj)) { switch (git_object_type(obj)) {
case GIT_OBJ_TREE: case GIT_OBJ_TREE:
*tree = (git_tree *)obj; *tree = (git_tree *)obj;
......
...@@ -182,6 +182,7 @@ static int submodule_from_config( ...@@ -182,6 +182,7 @@ static int submodule_from_config(
goto fail; goto fail;
sm->refcount++; sm->refcount++;
} }
git_buf_free(&name);
if (old_sm && ((git_submodule *)old_sm) != sm) { if (old_sm && ((git_submodule *)old_sm) != sm) {
/* TODO: log entry about multiple submodules with same path */ /* TODO: log entry about multiple submodules with same path */
...@@ -255,7 +256,7 @@ static int load_submodule_config(git_repository *repo) ...@@ -255,7 +256,7 @@ static int load_submodule_config(git_repository *repo)
GITERR_CHECK_ALLOC(smcfg); GITERR_CHECK_ALLOC(smcfg);
/* scan index for gitmodules (and .gitmodules entry) */ /* scan index for gitmodules (and .gitmodules entry) */
if ((error = git_repository_index(&index, repo)) < 0) if ((error = git_repository_index__weakptr(&index, repo)) < 0)
goto cleanup; goto cleanup;
memset(&gitmodules_oid, 0, sizeof(gitmodules_oid)); memset(&gitmodules_oid, 0, sizeof(gitmodules_oid));
max_i = git_index_entrycount(index); max_i = git_index_entrycount(index);
......
...@@ -17,25 +17,26 @@ void test_refs_unicode__cleanup(void) ...@@ -17,25 +17,26 @@ void test_refs_unicode__cleanup(void)
void test_refs_unicode__create_and_lookup(void) void test_refs_unicode__create_and_lookup(void)
{ {
git_reference *ref, *ref2; git_reference *ref0, *ref1, *ref2;
git_repository *repo2; git_repository *repo2;
const char *REFNAME = "refs/heads/" "\305" "ngstr" "\366" "m"; const char *REFNAME = "refs/heads/" "\305" "ngstr" "\366" "m";
const char *master = "refs/heads/master"; const char *master = "refs/heads/master";
/* Create the reference */ /* Create the reference */
cl_git_pass(git_reference_lookup(&ref, repo, master)); cl_git_pass(git_reference_lookup(&ref0, repo, master));
cl_git_pass(git_reference_create_oid(&ref, repo, REFNAME, git_reference_oid(ref), 0)); cl_git_pass(git_reference_create_oid(&ref1, repo, REFNAME, git_reference_oid(ref0), 0));
cl_assert(strcmp(REFNAME, git_reference_name(ref)) == 0); cl_assert(strcmp(REFNAME, git_reference_name(ref1)) == 0);
/* Lookup the reference in a different instance of the repository */ /* Lookup the reference in a different instance of the repository */
cl_git_pass(git_repository_open(&repo2, "testrepo.git")); cl_git_pass(git_repository_open(&repo2, "testrepo.git"));
cl_git_pass(git_reference_lookup(&ref2, repo2, REFNAME)); cl_git_pass(git_reference_lookup(&ref2, repo2, REFNAME));
cl_assert(git_oid_cmp(git_reference_oid(ref), git_reference_oid(ref2)) == 0); cl_assert(git_oid_cmp(git_reference_oid(ref1), git_reference_oid(ref2)) == 0);
cl_assert(strcmp(REFNAME, git_reference_name(ref2)) == 0); cl_assert(strcmp(REFNAME, git_reference_name(ref2)) == 0);
git_reference_free(ref); git_reference_free(ref0);
git_reference_free(ref1);
git_reference_free(ref2); git_reference_free(ref2);
git_repository_free(repo2); git_repository_free(repo2);
} }
...@@ -19,6 +19,7 @@ void test_status_submodules__initialize(void) ...@@ -19,6 +19,7 @@ void test_status_submodules__initialize(void)
p_rename("submodules/gitmodules", "submodules/.gitmodules"); p_rename("submodules/gitmodules", "submodules/.gitmodules");
cl_git_append2file("submodules/.gitmodules", modpath.ptr); cl_git_append2file("submodules/.gitmodules", modpath.ptr);
git_buf_free(&modpath);
p_rename("submodules/testrepo/.gitted", "submodules/testrepo/.git"); p_rename("submodules/testrepo/.gitted", "submodules/testrepo/.git");
} }
......
...@@ -127,6 +127,7 @@ void test_status_worktree__purged_worktree(void) ...@@ -127,6 +127,7 @@ void test_status_worktree__purged_worktree(void)
/* first purge the contents of the worktree */ /* first purge the contents of the worktree */
cl_git_pass(git_buf_sets(&workdir, git_repository_workdir(repo))); cl_git_pass(git_buf_sets(&workdir, git_repository_workdir(repo)));
cl_git_pass(git_path_direach(&workdir, remove_file_cb, NULL)); cl_git_pass(git_path_direach(&workdir, remove_file_cb, NULL));
git_buf_free(&workdir);
/* now get status */ /* now get status */
memset(&counts, 0x0, sizeof(struct status_entry_counts)); memset(&counts, 0x0, sizeof(struct status_entry_counts));
......
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