Skip to content

Commit 6990a49

Browse files
committed
revwalk: fix memory leak in error handling
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.
1 parent d55bb47 commit 6990a49

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/revwalk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ int git_revwalk_push_range(git_revwalk *walk, const char *range)
203203
if (revspec.flags & GIT_REVPARSE_MERGE_BASE) {
204204
/* TODO: support "<commit>...<commit>" */
205205
git_error_set(GIT_ERROR_INVALID, "symmetric differences not implemented in revwalk");
206-
return GIT_EINVALIDSPEC;
206+
error = GIT_EINVALIDSPEC;
207+
goto out;
207208
}
208209

209210
if ((error = push_commit(walk, git_object_id(revspec.from), 1, false)))

tests/revwalk/basic.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,15 @@ void test_revwalk_basic__push_range(void)
400400
cl_git_pass(test_walk_only(_walk, commit_sorting_segment, 2));
401401
}
402402

403+
void test_revwalk_basic__push_range_merge_base(void)
404+
{
405+
revwalk_basic_setup_walk(NULL);
406+
407+
git_revwalk_reset(_walk);
408+
git_revwalk_sorting(_walk, 0);
409+
cl_git_fail_with(GIT_EINVALIDSPEC, git_revwalk_push_range(_walk, "HEAD...HEAD~2"));
410+
}
411+
403412
void test_revwalk_basic__push_range_no_range(void)
404413
{
405414
revwalk_basic_setup_walk(NULL);

0 commit comments

Comments
 (0)