Always check the length of RzVector when accessing the tail elem
This commit is contained in:
parent
80cd0e9ae5
commit
e08ceb9bd7
1 changed files with 3 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue