diff options
Diffstat (limited to 'arraylist.c')
-rw-r--r-- | arraylist.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arraylist.c b/arraylist.c index 12ad8af..e5524ac 100644 --- a/arraylist.c +++ b/arraylist.c @@ -136,6 +136,9 @@ int array_list_del_idx(struct array_list *arr, size_t idx, size_t count) { size_t i, stop; + /* Avoid overflow in calculation with large indices. */ + if (idx > SIZE_T_MAX - count) + return -1; stop = idx + count; if (idx >= arr->length || stop > arr->length) return -1; |