[FFmpeg-devel] [PATCH 24/38] avcodec/libjxldec: respect side data preference

Anton Khirnov anton at khirnov.net
Fri Feb 23 15:58:46 EET 2024


From: Niklas Haas <git at haasn.dev>

Also fixes a memory leak where the side data was previously not properly
cleaned up on OOM, although we now unfortunately don't distinguish
between OOM and overriden side data.

Signed-off-by: Anton Khirnov <anton at khirnov.net>
---
 libavcodec/libjxldec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index b830eee784..e1dda99b73 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -483,9 +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);
+                AVFrameSideData *sd = ff_frame_new_side_data_from_buf(avctx, ctx->frame, AV_FRAME_DATA_ICC_PROFILE, ctx->iccp);
                 if (!sd)
-                    return AVERROR(ENOMEM);
+                    av_buffer_unref(&ctx->iccp);
                 /* ownership is transfered, and it is not ref-ed */
                 ctx->iccp = NULL;
             }
-- 
2.42.0



More information about the ffmpeg-devel mailing list