diff mbox series

[FFmpeg-devel,5/5] vulkan_decode: fix small memory leak

Message ID NXmzmsm--3-9@lynne.ee
State New
Headers show
Series [FFmpeg-devel,RFC,1/5] hwcontext: add a new AVHWFramesContext.opaque field | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch
andriy/configure_x86 warning Failed to apply patch

Commit Message

Lynne June 13, 2023, 4:24 a.m. UTC
This small memory leak was essentially responsible for keeping
decoding working at all.

The issue is that the codec profile must be attached to the frames
context. We created the codec profile at decoder creation time.
Which meant that if the decoder was destroyed, the context
became essentially useless, and segfaulted as the profile
was a hanging pointer.
This was an issue that happened when seeking through H264.

This requires using the new AVHWFramesContext.opaque field, as
otherwise, the profile attached to the decoder will be freed
before the frames context, rendering the frames context useless.

Patch attached.
diff mbox series

Patch

From 7d8f1c73308dd29dbf2d46dc09d85808aa1cc6be Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
Date: Tue, 13 Jun 2023 06:13:10 +0200
Subject: [PATCH 5/5] vulkan_decode: fix small memory leak

This requires using the new AVHWFramesContext.opaque field, as
otherwise, the profile attached to the decoder will be freed
before the frames context, rendering the frames context useless.
---
 libavcodec/vulkan_decode.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index 81085273d8..5aad8b213b 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -584,6 +584,8 @@  static void free_common(void *opaque, uint8_t *data)
                                           s->hwctx->alloc);
 
     ff_vk_uninit(s);
+
+    av_free(ctx);
 }
 
 static int vulkan_decode_bootstrap(AVCodecContext *avctx, AVBufferRef *frames_ref)
-- 
2.40.1