Skip to content

Commit

Permalink
fix some leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ethomson committed May 3, 2013
1 parent 42b2bcf commit d804163
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ static int diff_scan_inside_untracked_dir(
error = git_iterator_advance(&info->nitem, info->new_iter);
}

return error;
goto done;
}

/* look for actual untracked file */
Expand Down Expand Up @@ -747,6 +747,7 @@ static int diff_scan_inside_untracked_dir(
break;
}

done:
git_buf_free(&base);

return error;
Expand Down
1 change: 1 addition & 0 deletions src/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ static void index_free(git_index *index)
{
git_index_clear(index);
git_vector_free(&index->entries);
git_vector_free(&index->names);
git_vector_free(&index->reuc);

git__free(index->index_file_path);
Expand Down
6 changes: 6 additions & 0 deletions src/transports/smart_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ int git_smart__store_refs(transport_smart *t, int flushes)
int error, flush = 0, recvd;
const char *line_end;
git_pkt *pkt;
git_pkt_ref *ref;
size_t i;

/* Clear existing refs in case git_remote_connect() is called again
* after git_remote_disconnect().
*/
git_vector_foreach(refs, i, ref) {
git__free(ref->head.name);
git__free(ref);
}
git_vector_clear(refs);

do {
Expand Down
4 changes: 0 additions & 4 deletions tests-clar/commit/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,6 @@ This commit has a few LF at the start of the commit message";
\n\
This commit has a few LF at the start of the commit message";

commit = (git_commit*)git__malloc(sizeof(git_commit));
memset(commit, 0x0, sizeof(git_commit));
commit->object.repo = g_repo;

cl_git_pass(parse_commit(&commit, buffer));
cl_assert_equal_s(message, git_commit_message(commit));
git_commit__free(commit);
Expand Down
2 changes: 2 additions & 0 deletions tests-clar/submodule/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,6 @@ void test_submodule_status__untracked_dirs_containing_ignored_files(void)
GIT_SUBMODULE_STATUS_IN_WD;

cl_assert(status == expected);

git_buf_free(&path);
}

0 comments on commit d804163

Please sign in to comment.