From 3a75cd0ad3af0b4fceb9c53cf593ea94cd8de263 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 13 Oct 2026 06:06:59 +0200 Subject: [PATCH] swscale/graph: copy the palette of a PAL8 frame as a whole Fixes: NwCWHv3RIJff Fixes: use of uninitialized memory Use of uninitialized memory Replicated through API with MSAN Found during triage of the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24851 --- libswscale/graph.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libswscale/graph.c b/libswscale/graph.c index 664dd1c1c3..73319a135d 100644 --- a/libswscale/graph.c +++ b/libswscale/graph.c @@ -290,6 +290,12 @@ static void run_copy(const SwsFrame *out, const SwsFrame *in, int y, int h, const int lines = h >> ff_fmt_vshift(in->format, i); av_assert1(in_data[i]); + if (i == 1 && av_pix_fmt_desc_get(in->format)->flags & AV_PIX_FMT_FLAG_PAL) { + if (!y && in->data[1] != out->data[1]) + memcpy(out->data[1], in->data[1], AVPALETTE_SIZE); + break; + } + if (in_data[i] == out_data[i]) { av_assert0(in->linesize[i] == out->linesize[i]); } else if (in->linesize[i] == out->linesize[i]) {