From 55136c30c4c145b4c7b78ec19179b6cf140c71a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Brzezi=C5=84ski?= Date: Thu, 14 Mar 2024 13:30:24 +0100 Subject: [PATCH] avaudenc: Avoid double-freeing frame's extended data This occured when attempting to encode 16 channel audio, would crash on the first buffer. We only need to store ext_data, old ext_data_array (frame->extended_data) is already freed by `av_frame_unref`. Part-of: --- subprojects/gst-libav/ext/libav/gstavaudenc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-libav/ext/libav/gstavaudenc.c b/subprojects/gst-libav/ext/libav/gstavaudenc.c index 5651ce07e9..57f41fe617 100644 --- a/subprojects/gst-libav/ext/libav/gstavaudenc.c +++ b/subprojects/gst-libav/ext/libav/gstavaudenc.c @@ -403,7 +403,7 @@ typedef struct GstBuffer *buffer; GstMapInfo map; - guint8 **ext_data_array, *ext_data; + guint8 *ext_data; } BufferInfo; static void @@ -416,7 +416,6 @@ buffer_info_free (void *opaque, guint8 * data) gst_buffer_unref (info->buffer); } else { av_freep (&info->ext_data); - av_freep (&info->ext_data_array); } g_free (info); } @@ -473,7 +472,7 @@ gst_ffmpegaudenc_send_frame (GstFFMpegAudEnc * ffmpegaudenc, GstBuffer * buffer) av_buffer_create (NULL, 0, buffer_info_free, buffer_info, 0); if (info->channels > AV_NUM_DATA_POINTERS) { - buffer_info->ext_data_array = frame->extended_data = + frame->extended_data = av_malloc_array (info->channels, sizeof (uint8_t *)); } else { frame->extended_data = frame->data;