Commit bbd37149e4 for ffmpeg
commit bbd37149e4b1bd9730a70f06b72d1c1f9b95bc0f
Author: Leo Izen <leo.izen@gmail.com>
Date: Sat Oct 17 12:49:36 2026 -0400
avcodec/pngdec: avoid implementation-defined right-shift behavior
Right shifting a negative-signed integer has implementation-defined
behavior with regard to sign-extending or zero-extending. Taking the
result and a bitwise-and mask makes this work regardless of that
behavior.
Signed-off-by: Leo Izen <leo.izen@gmail.com>
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index f20cef76d9..58c688e51f 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -520,7 +520,7 @@ static char *iso88591_to_utf8(const char *in, size_t size_in)
return NULL;
for (i = 0; i < size_in; i++) {
if (in[i] & 0x80) {
- *(q++) = 0xC0 | (in[i] >> 6);
+ *(q++) = 0xC0 | ((in[i] >> 6) & 0x3);
*(q++) = 0x80 | (in[i] & 0x3F);
} else {
*(q++) = in[i];