Skip to content

Commit

Permalink
Always check the length of RzVector when accessing the tail elem
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio committed Apr 23, 2024
1 parent b2a4f6c commit 6e9bbbc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions librz/include/rz_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ static inline void *rz_vector_head(const RzVector *vec) {
// returns a pointer to the last element of the vector
static inline void *rz_vector_tail(RzVector *vec) {
rz_return_val_if_fail(vec, NULL);
if (vec->len < 1) {
return NULL;
}
return (char *)vec->a + vec->elem_size * (vec->len - 1);
}

Expand Down

0 comments on commit 6e9bbbc

Please sign in to comment.