File ffmpeg-6-CVE-2024-35368.patch of Package A_slowroll-ffmpeg-6

37
 
1
From 4513300989502090c4fd6560544dce399a8cd53c Mon Sep 17 00:00:00 2001
2
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3
Date: Sun, 24 Sep 2023 13:15:48 +0200
4
Subject: [PATCH] avcodec/rkmppdec: Fix double-free on error
5
6
After having created the AVBuffer that is put into frame->buf[0],
7
ownership of several objects (namely an AVDRMFrameDescriptor,
8
an MppFrame and some AVBufferRefs framecontextref and decoder_ref)
9
has passed to the AVBuffer and therefore to the frame.
10
Yet it has nevertheless been freed manually on error
11
afterwards, which would lead to a double-free as soon
12
as the AVFrame is unreferenced.
13
14
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
15
---
16
 libavcodec/rkmppdec.c | 4 ++--
17
 1 file changed, 2 insertions(+), 2 deletions(-)
18
19
diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
20
index 7665098c6a..6889545b20 100644
21
--- a/libavcodec/rkmppdec.c
22
+++ b/libavcodec/rkmppdec.c
23
@@ -463,8 +463,8 @@ static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
24
25
             frame->hw_frames_ctx = av_buffer_ref(decoder->frames_ref);
26
             if (!frame->hw_frames_ctx) {
27
-                ret = AVERROR(ENOMEM);
28
-                goto fail;
29
+                av_frame_unref(frame);
30
+                return AVERROR(ENOMEM);
31
             }
32
33
             return 0;
34
--
35
2.41.0
36
37