[FFmpeg-devel] [PATCH 1/2] avio_alloc_context: Allocate a buffer if NULL is passed

Michael Niedermayer michaelni at gmx.at
Wed May 21 22:18:52 CEST 2014


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavformat/aviobuf.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 738459e..e60574d 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -119,6 +119,15 @@ AVIOContext *avio_alloc_context(
     AVIOContext *s = av_mallocz(sizeof(AVIOContext));
     if (!s)
         return NULL;
+    if (!buffer && !buffer_size)
+        buffer_size = IO_BUFFER_SIZE;
+    if (!buffer) {
+        buffer = av_malloc(buffer_size);
+        if (!buffer) {
+            av_free(s);
+            return NULL;
+        }
+    }
     ffio_init_context(s, buffer, buffer_size, write_flag, opaque,
                   read_packet, write_packet, seek);
     return s;
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list