Skip to content

Commit f47db3c

Browse files
committed
vector: do not reverse a vector if it is empty
The code reversing a vector initially determines the rear-pointer by simply subtracting 1 from the vector's length. Obviously, this fails if the vector is empty, in which case we have an integer overflow. Fix the issue by returning early if the vector is empty.
1 parent 390431c commit f47db3c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-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

0 commit comments

Comments
 (0)