[FFmpeg-devel] [PATCH] Fix av_open_input_stream with uninitialized context pointer.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Jul 5 23:13:05 CEST 2011


Code would allocated a new context but forget to assign it
to the pointer actually passed to ic_ptr, potentially causing a crash.
Even when it is initialized it would cause a memleak.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 libavformat/utils.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index cd90480..c990657 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -457,7 +457,7 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
     opts = convert_format_parameters(ap);
 
     if(!ap->prealloced_context)
-        ic = avformat_alloc_context();
+        *ic_ptr = ic = avformat_alloc_context();
     else
         ic = *ic_ptr;
     if (!ic) {
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list