Fixed underflow in ev_vec_pop

This commit is contained in:
2026-04-21 14:06:30 +02:00
parent 76a5bf0afa
commit 7663c76329
+5 -2
View File
@@ -45,7 +45,8 @@ typedef void *ev_svec_t;
typedef enum {
EV_VEC_ERR_NONE = 0,
EV_VEC_ERR_OOM = 1
EV_VEC_ERR_OOM = -1,
EV_VEC_ERR_INVALID_OP = -2
} ev_vec_error_t;
TYPEDATA_GEN(ev_vec_error_t, DEFAULT(EV_VEC_ERR_NONE));
@@ -252,7 +253,7 @@ ev_vec_fini(
* vector
*
* \returns The index of the element that was just pushed. If the operation
* failed, a non-zero (vec_error_t) value is returned.
* failed, a less-than-zero (vec_error_t) value is returned.
*/
EV_VEC_API int
ev_vec_push_impl(
@@ -640,6 +641,8 @@ ev_vec_pop(
ev_vec_t* v = (ev_vec_t*)vec_p;
__ev_vec_getmeta(*v)
if(metadata->length == 0) return EV_VEC_ERR_INVALID_OP;
if(out != NULL) {
void *src = ((char *)*v) + ((metadata->length-1) * metadata->typeData.size);
if (metadata->typeData.copy_fn) {