From 0303431e717c25ff55a8a984a608de41cab91b3e Mon Sep 17 00:00:00 2001 From: askmeaboutloom Date: Mon, 15 Aug 2022 19:26:34 +0200 Subject: [PATCH] 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. --- mypaint-brush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypaint-brush.c b/mypaint-brush.c index cdb644fb..95332655 100644 --- a/mypaint-brush.c +++ b/mypaint-brush.c @@ -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;