Commit fe21d708 by Carlos Martín Nieto

Plug a few leaks

parent 9ce97782
...@@ -277,7 +277,7 @@ static int normalize_find_opts( ...@@ -277,7 +277,7 @@ static int normalize_find_opts(
if (!given || if (!given ||
(given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG) (given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG)
{ {
const char *rule = char *rule =
git_config__get_string_force(cfg, "diff.renames", "true"); git_config__get_string_force(cfg, "diff.renames", "true");
int boolval; int boolval;
...@@ -287,6 +287,8 @@ static int normalize_find_opts( ...@@ -287,6 +287,8 @@ static int normalize_find_opts(
opts->flags |= GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES; opts->flags |= GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES;
else else
opts->flags |= GIT_DIFF_FIND_RENAMES; opts->flags |= GIT_DIFF_FIND_RENAMES;
git__free(rule);
} }
/* some flags imply others */ /* some flags imply others */
......
...@@ -466,11 +466,11 @@ static int rebase_normalize_opts( ...@@ -466,11 +466,11 @@ static int rebase_normalize_opts(
opts->rewrite_notes_ref = git__strdup(given_opts->rewrite_notes_ref); opts->rewrite_notes_ref = git__strdup(given_opts->rewrite_notes_ref);
GITERR_CHECK_ALLOC(opts->rewrite_notes_ref); GITERR_CHECK_ALLOC(opts->rewrite_notes_ref);
} else if (git_config__get_bool_force(config, "notes.rewrite.rebase", 1)) { } else if (git_config__get_bool_force(config, "notes.rewrite.rebase", 1)) {
const char *rewrite_ref = git_config__get_string_force( char *rewrite_ref = git_config__get_string_force(
config, "notes.rewriteref", NOTES_DEFAULT_REF); config, "notes.rewriteref", NOTES_DEFAULT_REF);
if (rewrite_ref) { if (rewrite_ref) {
opts->rewrite_notes_ref = git__strdup(rewrite_ref); opts->rewrite_notes_ref = rewrite_ref;
GITERR_CHECK_ALLOC(opts->rewrite_notes_ref); GITERR_CHECK_ALLOC(opts->rewrite_notes_ref);
} }
} }
......
...@@ -1075,7 +1075,7 @@ int git_reference__update_terminal( ...@@ -1075,7 +1075,7 @@ int git_reference__update_terminal(
const git_signature *sig, const git_signature *sig,
const char *log_message) const char *log_message)
{ {
git_reference *ref = NULL; git_reference *ref = NULL, *ref2 = NULL;
git_signature *who = NULL; git_signature *who = NULL;
const git_signature *to_use; const git_signature *to_use;
int error = 0; int error = 0;
...@@ -1090,18 +1090,20 @@ int git_reference__update_terminal( ...@@ -1090,18 +1090,20 @@ int git_reference__update_terminal(
if (error == GIT_ENOTFOUND && ref) { if (error == GIT_ENOTFOUND && ref) {
assert(git_reference_type(ref) == GIT_REF_SYMBOLIC); assert(git_reference_type(ref) == GIT_REF_SYMBOLIC);
giterr_clear(); giterr_clear();
error = reference__create(&ref, repo, ref->target.symbolic, oid, NULL, 0, to_use, error = reference__create(&ref2, repo, ref->target.symbolic, oid, NULL, 0, to_use,
log_message, NULL, NULL); log_message, NULL, NULL);
} else if (error == GIT_ENOTFOUND) { } else if (error == GIT_ENOTFOUND) {
giterr_clear(); giterr_clear();
error = reference__create(&ref, repo, ref_name, oid, NULL, 0, to_use, error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use,
log_message, NULL, NULL); log_message, NULL, NULL);
} else if (error == 0) { } else if (error == 0) {
assert(git_reference_type(ref) == GIT_REF_OID); assert(git_reference_type(ref) == GIT_REF_OID);
error = reference__create(&ref, repo, ref->name, oid, NULL, 1, to_use, error = reference__create(&ref2, repo, ref->name, oid, NULL, 1, to_use,
log_message, &ref->target.oid, NULL); log_message, &ref->target.oid, NULL);
} }
git_reference_free(ref2);
git_reference_free(ref);
git_signature_free(who); git_signature_free(who);
return error; return error;
} }
......
...@@ -1948,6 +1948,7 @@ int git_repository_set_head( ...@@ -1948,6 +1948,7 @@ int git_repository_set_head(
} }
cleanup: cleanup:
git_buf_free(&log_message);
git_reference_free(current); git_reference_free(current);
git_reference_free(ref); git_reference_free(ref);
git_reference_free(new_head); git_reference_free(new_head);
...@@ -1980,6 +1981,7 @@ int git_repository_set_head_detached( ...@@ -1980,6 +1981,7 @@ int git_repository_set_head_detached(
error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_object_id(peeled), true, git_buf_cstr(&log_message)); error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_object_id(peeled), true, git_buf_cstr(&log_message));
cleanup: cleanup:
git_buf_free(&log_message);
git_object_free(object); git_object_free(object);
git_object_free(peeled); git_object_free(peeled);
git_reference_free(current); git_reference_free(current);
...@@ -2012,6 +2014,7 @@ int git_repository_detach_head(git_repository* repo) ...@@ -2012,6 +2014,7 @@ int git_repository_detach_head(git_repository* repo)
1, git_buf_cstr(&log_message)); 1, git_buf_cstr(&log_message));
cleanup: cleanup:
git_buf_free(&log_message);
git_object_free(object); git_object_free(object);
git_reference_free(old_head); git_reference_free(old_head);
git_reference_free(new_head); git_reference_free(new_head);
......
...@@ -128,5 +128,6 @@ void test_config_include__depth2(void) ...@@ -128,5 +128,6 @@ void test_config_include__depth2(void)
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar2")); cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar2"));
cl_assert_equal_s("baz2", git_buf_cstr(&buf)); cl_assert_equal_s("baz2", git_buf_cstr(&buf));
git_buf_free(&buf);
git_config_free(cfg); git_config_free(cfg);
} }
...@@ -221,4 +221,6 @@ void test_reset_hard__reflog_is_correct(void) ...@@ -221,4 +221,6 @@ void test_reset_hard__reflog_is_correct(void)
cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL)); cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
reflog_check(repo, "HEAD", 4, NULL, git_buf_cstr(&buf)); reflog_check(repo, "HEAD", 4, NULL, git_buf_cstr(&buf));
reflog_check(repo, "refs/heads/master", 4, NULL, git_buf_cstr(&buf)); reflog_check(repo, "refs/heads/master", 4, NULL, git_buf_cstr(&buf));
git_buf_free(&buf);
} }
...@@ -72,4 +72,6 @@ void test_reset_mixed__reflog_is_correct(void) ...@@ -72,4 +72,6 @@ void test_reset_mixed__reflog_is_correct(void)
cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL)); cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL));
reflog_check(repo, "HEAD", 10, NULL, git_buf_cstr(&buf)); reflog_check(repo, "HEAD", 10, NULL, git_buf_cstr(&buf));
reflog_check(repo, "refs/heads/master", 10, NULL, git_buf_cstr(&buf)); reflog_check(repo, "refs/heads/master", 10, NULL, git_buf_cstr(&buf));
git_buf_free(&buf);
} }
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