[FFmpeg-devel] [PATCH] avformat/options: don't call avformat_free_context() within avformat_alloc_context()

James Almer jamrial at gmail.com
Sat Oct 19 18:03:42 EEST 2019


avformat_free_context() expects AVFormatContext->internal to not be NULL.

Signed-off-by: James Almer <jamrial at gmail.com>
---
Alternatively we could check for internal != NULL in avformat_free_context()
before dereferencing it, but i don't think it makes sense calling that function
at all if the AVFormatContext wasn't even fully allocated to begin with.

 libavformat/options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/options.c b/libavformat/options.c
index c188c23506..9a6deed0df 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -150,7 +150,7 @@ AVFormatContext *avformat_alloc_context(void)
 
     ic->internal = av_mallocz(sizeof(*ic->internal));
     if (!ic->internal) {
-        avformat_free_context(ic);
+        av_free(ic);
         return NULL;
     }
     ic->internal->offset = AV_NOPTS_VALUE;
-- 
2.23.0



More information about the ffmpeg-devel mailing list