From bfe3277a622bc8a90b2dfb41ad97e90c8fc561f7 Mon Sep 17 00:00:00 2001 From: Jesse Yurkovich Date: Thu, 16 Jan 2025 21:09:46 -0800 Subject: [PATCH] Fix #4599: Perform endian byteswap on correct buffer area for PSD RLE decoding Signed-off-by: Jesse Yurkovich --- src/psd.imageio/psdinput.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/psd.imageio/psdinput.cpp b/src/psd.imageio/psdinput.cpp index de171fed7b..3d849f8e5f 100644 --- a/src/psd.imageio/psdinput.cpp +++ b/src/psd.imageio/psdinput.cpp @@ -2233,6 +2233,7 @@ PSDInput::decompress_packbits(const char* src, char* dst, int16_t header; int length; + char* dst_start = dst; while (src_remaining > 0 && dst_remaining > 0) { header = *reinterpret_cast(src); src++; @@ -2275,8 +2276,8 @@ PSDInput::decompress_packbits(const char* src, char* dst, if (!bigendian()) { switch (m_header.depth) { - case 16: swap_endian((uint16_t*)dst, m_spec.width); break; - case 32: swap_endian((uint32_t*)dst, m_spec.width); break; + case 16: swap_endian((uint16_t*)dst_start, m_spec.width); break; + case 32: swap_endian((uint32_t*)dst_start, m_spec.width); break; } }