Skip to content

Commit 7dcb04b

Browse files
askmeaboutlo0mjtojnar
authored andcommitted
Fix off by one error when clearing smudge buckets
The max_buckets_used value is _inclusive_, so an additional +1 is necessary to clear the last used bucket.
1 parent 6ca1c93 commit 7dcb04b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mypaint-brush.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ brush_reset(MyPaintBrush *self)
158158
int min_index = self->min_bucket_used;
159159
if (min_index != -1) {
160160
int max_index = self->max_bucket_used;
161-
size_t num_bytes = (max_index - min_index) * sizeof(self->smudge_buckets[0]) * SMUDGE_BUCKET_SIZE;
161+
size_t num_bytes = (max_index - min_index + 1) * sizeof(self->smudge_buckets[0]) * SMUDGE_BUCKET_SIZE;
162162
memset(self->smudge_buckets + min_index, 0, num_bytes);
163163
self->min_bucket_used = -1;
164164
self->max_bucket_used = -1;

0 commit comments

Comments
 (0)