Skip to content

Commit 104a1b0

Browse files
author
Edward Thomson
authored
Merge pull request libgit2#4105 from pks-t/pks/vector-reverse-overflow
Vector reverse overflow
2 parents 9ba610a + f47db3c commit 104a1b0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/vector.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ void git_vector_reverse(git_vector *v)
406406
{
407407
size_t a, b;
408408

409+
if (v->length == 0)
410+
return;
411+
409412
a = 0;
410413
b = v->length - 1;
411414

tests/revwalk/basic.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,20 @@ void test_revwalk_basic__hide_then_push(void)
331331
cl_assert_equal_i(i, 0);
332332
}
333333

334+
void test_revwalk_basic__topo_crash(void)
335+
{
336+
git_oid oid;
337+
git_oid_fromstr(&oid, "5b5b025afb0b4c913b4c338a42934a3863bf3644");
338+
339+
revwalk_basic_setup_walk(NULL);
340+
git_revwalk_sorting(_walk, GIT_SORT_TOPOLOGICAL);
341+
342+
cl_git_pass(git_revwalk_push(_walk, &oid));
343+
cl_git_pass(git_revwalk_hide(_walk, &oid));
344+
345+
git_revwalk_next(&oid, _walk);
346+
}
347+
334348
void test_revwalk_basic__push_range(void)
335349
{
336350
revwalk_basic_setup_walk(NULL);

0 commit comments

Comments
 (0)