Skip to content

Commit

Permalink
revwalk: fix memory leak in error handling
Browse files Browse the repository at this point in the history
This is not implemented and should fail, but it should also not leak. To
allow the memory debugger to find leaks and fix this one we test this.
  • Loading branch information
hvoigt committed May 10, 2019
1 parent d55bb47 commit 6990a49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/revwalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ int git_revwalk_push_range(git_revwalk *walk, const char *range)
if (revspec.flags & GIT_REVPARSE_MERGE_BASE) {
/* TODO: support "<commit>...<commit>" */
git_error_set(GIT_ERROR_INVALID, "symmetric differences not implemented in revwalk");
return GIT_EINVALIDSPEC;
error = GIT_EINVALIDSPEC;
goto out;
}

if ((error = push_commit(walk, git_object_id(revspec.from), 1, false)))
Expand Down
9 changes: 9 additions & 0 deletions tests/revwalk/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,15 @@ void test_revwalk_basic__push_range(void)
cl_git_pass(test_walk_only(_walk, commit_sorting_segment, 2));
}

void test_revwalk_basic__push_range_merge_base(void)
{
revwalk_basic_setup_walk(NULL);

git_revwalk_reset(_walk);
git_revwalk_sorting(_walk, 0);
cl_git_fail_with(GIT_EINVALIDSPEC, git_revwalk_push_range(_walk, "HEAD...HEAD~2"));
}

void test_revwalk_basic__push_range_no_range(void)
{
revwalk_basic_setup_walk(NULL);
Expand Down

0 comments on commit 6990a49

Please sign in to comment.