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 <hhhuang@smu.edu.sg>
This commit is contained in:
Huihui_Huang
2026-03-17 15:56:15 +08:00
parent ac4d50cb26
commit 6e37545d6b

View File

@@ -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);