Skip to content

Commit

Permalink
Fix off by one error when clearing smudge buckets
Browse files Browse the repository at this point in the history
The max_buckets_used value is _inclusive_, so an additional +1 is
necessary to clear the last used bucket.
  • Loading branch information
askmeaboutlo0m authored and jtojnar committed Aug 4, 2024
1 parent 6ca1c93 commit 0303431
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mypaint-brush.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ brush_reset(MyPaintBrush *self)
int min_index = self->min_bucket_used;
if (min_index != -1) {
int max_index = self->max_bucket_used;
size_t num_bytes = (max_index - min_index) * sizeof(self->smudge_buckets[0]) * SMUDGE_BUCKET_SIZE;
size_t num_bytes = (max_index - min_index + 1) * sizeof(self->smudge_buckets[0]) * SMUDGE_BUCKET_SIZE;
memset(self->smudge_buckets + min_index, 0, num_bytes);
self->min_bucket_used = -1;
self->max_bucket_used = -1;
Expand Down

0 comments on commit 0303431

Please sign in to comment.