Skip to content

Commit f6b50a5

Browse files
authored
Improved BCn overflow check (#9043)
2 parents 8d801bc + 73e1ed9 commit f6b50a5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libImaging/BcnEncode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ ImagingBcnEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) {
257257

258258
UINT8 *dst = buf;
259259

260+
int will_write = (n == 2 || n == 3 || n == 5) ? 16 : 8;
260261
for (;;) {
261-
// Loop writes a max of 16 bytes per iteration
262-
if (dst + 16 >= bytes + buf) {
262+
if (dst + will_write >= bytes + buf) {
263263
break;
264264
}
265265
if (n == 5) {

0 commit comments

Comments
 (0)