From 6e9bbbc91e0ea402e132b659e85829f8042e07c8 Mon Sep 17 00:00:00 2001 From: wargio Date: Tue, 23 Apr 2024 10:36:40 +0800 Subject: [PATCH] Always check the length of RzVector when accessing the tail elem --- librz/include/rz_vector.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/librz/include/rz_vector.h b/librz/include/rz_vector.h index 3d627a7d203..5cd46fe0e15 100644 --- a/librz/include/rz_vector.h +++ b/librz/include/rz_vector.h @@ -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); }