From 6e37545d6be7fb3bd74a4766eb0712ed443603bb Mon Sep 17 00:00:00 2001 From: Huihui_Huang Date: Tue, 17 Mar 2026 15:56:15 +0800 Subject: [PATCH] swscale: fix possible lut leak in adapt_colors() adapt_colors() allocates a SwsLut3D before calling add_convert_pass(). If add_convert_pass() fails, the function returns without freeing the previously allocated lut. Free lut on that error path. Signed-off-by: Huihui_Huang --- libswscale/graph.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libswscale/graph.c b/libswscale/graph.c index db11591862..3b16037767 100644 --- a/libswscale/graph.c +++ b/libswscale/graph.c @@ -702,8 +702,10 @@ static int adapt_colors(SwsGraph *graph, SwsFormat src, SwsFormat dst, SwsFormat tmp = src; tmp.format = fmt_in; ret = add_convert_pass(graph, &src, &tmp, input, &input); - if (ret < 0) + if (ret < 0) { + ff_sws_lut3d_free(&lut); return ret; + } } ret = ff_sws_lut3d_generate(lut, fmt_in, fmt_out, &map);