add: safety bound checks for vec_get

This commit is contained in:
javalsai 2024-11-01 13:11:01 +01:00
parent d7bfa79284
commit 49e3ad528f
Signed by: javalsai
SSH Key Fingerprint: SHA256:3G83yKhBUWVABVX/vPWH88xnK4+ptMtHkZGCRXD4Mk8

View File

@ -121,5 +121,8 @@ void* vec_pop(struct Vector* vec) {
} }
void* vec_get(struct Vector* vec, uint32_t index) { void* vec_get(struct Vector* vec, uint32_t index) {
if (index >= vec->length)
return NULL;
return vec->pages[index]; return vec->pages[index];
} }