mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-28 08:58:41 +00:00
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.
This commit is contained in:
parent
390431c322
commit
f47db3c799
@ -406,6 +406,9 @@ void git_vector_reverse(git_vector *v)
|
||||
{
|
||||
size_t a, b;
|
||||
|
||||
if (v->length == 0)
|
||||
return;
|
||||
|
||||
a = 0;
|
||||
b = v->length - 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user