From 6f8cc7bb6a77e7b03751051be86a0c6b36bdd86f Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Mon, 5 Aug 2013 20:06:09 -0500 Subject: [PATCH] Fix warning, fix memory leak --- src/checkout_conflicts.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/checkout_conflicts.c b/src/checkout_conflicts.c index dcf27145d..eb1ac6e14 100644 --- a/src/checkout_conflicts.c +++ b/src/checkout_conflicts.c @@ -56,14 +56,16 @@ static int checkout_conflictdata_cmp(const void *a, const void *b) int checkout_conflictdata_empty(const git_vector *conflicts, size_t idx) { - const checkout_conflictdata *conflict; + checkout_conflictdata *conflict; if ((conflict = git_vector_get(conflicts, idx)) == NULL) return -1; - return (conflict->ancestor == NULL && - conflict->ours == NULL && - conflict->theirs == NULL); + if (conflict->ancestor || conflict->ours || conflict->theirs) + return 0; + + git__free(conflict); + return 1; } static int checkout_conflicts_load(checkout_data *data, git_vector *conflicts) @@ -409,8 +411,7 @@ static int checkout_write_entry( const char *hint_path = NULL, *suffix; struct stat st; - assert (side == conflict->ours || - side == conflict->theirs); + assert (side == conflict->ours || side == conflict->theirs); git_buf_truncate(&data->path, data->workdir_len); if (git_buf_puts(&data->path, side->path) < 0) @@ -423,7 +424,7 @@ static int checkout_write_entry( if (side == conflict->ours) suffix = data->opts.our_label ? data->opts.our_label : "ours"; - else if (side == conflict->theirs) + else suffix = data->opts.their_label ? data->opts.their_label : "theirs"; @@ -456,7 +457,7 @@ static int checkout_merge_path( git_merge_file_result *result) { const char *our_label_raw, *their_label_raw, *suffix; - int i = 0, error = 0; + int error = 0; if ((error = git_buf_joinpath(out, git_repository_workdir(data->repo), result->path)) < 0) return error;