diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-02 16:46:56 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-02 16:52:13 +0100 |
commit | 0a1524f4f6f791fde05e681fbabd0787636ebced (patch) | |
tree | ac127563886006ac537faaaf34f0c20b6261309f | |
parent | 438a07bf89541d2baec53e69cc22eb3301a9d244 (diff) |
src/anim: fix off-by-one oob write for bitmaps
-rw-r--r-- | src/anim-atlas.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp index 434f34b6..8ddd73d6 100644 --- a/src/anim-atlas.cpp +++ b/src/anim-atlas.cpp @@ -158,11 +158,13 @@ void anim_atlas::make_bitmask_(const ImageView2D& tex, BitArray& array) (unsigned char)(buf[7*4] >= amin) << 7); dest[dst_idx] = value; } - dest[(height-j-1)*width+i >> 3] = 0; - for (; i < width; i++) + if (i < width) { - unsigned char alpha = data[(j*stride + i*4)+3]; - array.set((height-j-1)*width + i, alpha >= amin); + dest[(height-j-1)*width+i >> 3] = 0; + do { + unsigned char alpha = data[(j*stride + i*4)+3]; + array.set((height-j-1)*width + i, alpha >= amin); + } while (++i < width); } } } |