From 6e5d3e2d81bd7f17a9e713666d0bc01aa1896223 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 25 May 2022 21:37:28 +0300
Subject: [PATCH] backport fix for
https://github.com/libsdl-org/SDL_image/issues/266
---
IMG_pcx.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/IMG_pcx.c b/IMG_pcx.c
index c406eff6..dd86ae1d 100644
--- a/IMG_pcx.c
+++ b/IMG_pcx.c
@@ -219,7 +219,7 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src)
} else if(src_bits == 8) {
/* Copy the row directly */
memcpy(row, buf, SDL_min(width, bpl));
- } else if(src_bits == 24) {
+ } else if(src_bits == 24) {
/* de-interlace planes */
Uint8 *innerSrc = buf;
Uint8 *end1 = buf+bpl;
@@ -229,13 +229,14 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src)
Uint8 *dst = row + plane;
Uint8 *end2= row + surface->pitch;
for(x = 0; x < width; x++) {
- if (innerSrc >= end1 || dst >= end2) {
+ if ((innerSrc + x) >= end1 || dst >= end2) {
error = "decoding out of bounds (corrupt?)";
goto done;
}
- *dst = *innerSrc++;
+ *dst = innerSrc[x];
dst += pcxh.NPlanes;
}
+ innerSrc += pcxh.BytesPerLine;
}
}