Skip to content

Commit

Permalink
add: safety bound checks for vec_get
Browse files Browse the repository at this point in the history
  • Loading branch information
javalsai committed Nov 1, 2024
1 parent d7bfa79 commit 49e3ad5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,8 @@ void* vec_pop(struct Vector* vec) {
}

void* vec_get(struct Vector* vec, uint32_t index) {
if (index >= vec->length)
return NULL;

return vec->pages[index];
}

0 comments on commit 49e3ad5

Please sign in to comment.