Skip to content

Commit

Permalink
Fixing an off-by-one bug in 'array_remove_at'
Browse files Browse the repository at this point in the history
  • Loading branch information
srdja committed Feb 21, 2019
1 parent 05502c1 commit 6722031
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ enum cc_stat array_remove_at(Array *ar, size_t index, void **out)
*out = ar->buffer[index];

if (index != ar->size - 1) {
size_t block_size = (ar->size - index) * sizeof(void*);
size_t block_size = (ar->size - 1 - index) * sizeof(void*);

memmove(&(ar->buffer[index]),
&(ar->buffer[index + 1]),
Expand Down

0 comments on commit 6722031

Please sign in to comment.