PR #25155 opened by Leo Izen (Traneptora) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25155 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25155.patch
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 <[email protected]> # Summary of changes Briefly describe what this PR does and why. <!-- If this PR requires new FATE test samples, attach them to the PR and list their target paths below (relative to the fate-suite root). Attached filenames must match the sample's filename: ```fate-samples # e.g. vorbis/new-sample.ogg ``` --> >From 54d7786aadaac21e42d713a36392e5f6aec5076a Mon Sep 17 00:00:00 2001 From: Leo Izen <[email protected]> Date: Sat, 17 Oct 2026 12:49:36 -0400 Subject: [PATCH] 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 <[email protected]> --- libavcodec/pngdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 3af36f47e1..62fa61e566 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -516,7 +516,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]; -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
