diff mbox series

[FFmpeg-devel,15/29] avcodec/libjxldec: respect side data preference

Message ID 20240304130657.30631-15-anton@khirnov.net
State Accepted
Commit 62f40d0e3856954a6b2bc20dc70bea52e57c31ad
Headers show
Series [FFmpeg-devel,01/29] lavu/opt: factor per-type dispatch out of av_opt_get() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov March 4, 2024, 1:06 p.m. UTC
From: Niklas Haas <git@haasn.dev>

Also fixes a memory leak where the side data was previously not properly
cleaned up on OOM.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
---
 libavcodec/libjxldec.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index b830eee784..d57a27418f 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -483,11 +483,9 @@  static int libjxl_receive_frame(AVCodecContext *avctx, AVFrame *frame)
             /* full image is one frame, even if animated */
             av_log(avctx, AV_LOG_DEBUG, "FULL_IMAGE event emitted\n");
             if (ctx->iccp) {
-                AVFrameSideData *sd = av_frame_new_side_data_from_buf(ctx->frame, AV_FRAME_DATA_ICC_PROFILE, ctx->iccp);
-                if (!sd)
-                    return AVERROR(ENOMEM);
-                /* ownership is transfered, and it is not ref-ed */
-                ctx->iccp = NULL;
+                ret = ff_frame_new_side_data_from_buf(avctx, ctx->frame, AV_FRAME_DATA_ICC_PROFILE, &ctx->iccp, NULL);
+                if (ret < 0)
+                    return ret;
             }
             if (ctx->basic_info.have_animation) {
                 ctx->frame->pts = av_rescale_q(ctx->accumulated_pts, ctx->anim_timebase, avctx->pkt_timebase);