[FFmpeg-devel] Bug in av_open_input_stream() since r11071 (ByteIOContext change) [2nd try to send]

Stefan Lucke stefan
Sat Dec 22 08:59:15 CET 2007


old version from r11007 looks like:

int av_open_input_stream(AVFormatContext **ic_ptr,
                         ByteIOContext *pb, const char *filename,
                         AVInputFormat *fmt, AVFormatParameters *ap)
{
    int err;
    AVFormatContext *ic;
    AVFormatParameters default_ap;

    if(!ap){
        ap=&default_ap;
        memset(ap, 0, sizeof(default_ap));
    }

    if(!ap->prealloced_context)
        ic = av_alloc_format_context();
    else
        ic = *ic_ptr;
    if (!ic) {
        err = AVERROR(ENOMEM);
        goto fail;
    }
    ic->iformat = fmt;
    if (pb)
        ic->pb = *pb;

This instruction was a structure-copy if an address of a
ByteIOContext is supplied.
ic's own ByteIOContext was initialized in av_alloc_format_context();

In current svn version (r11278), supplied parameter pointer gets ic's
pb despite of it's value.

line 377: ic->pb = pb;

It may be NULL in case current format has AVFMT_NOFILE set.

Attached patch fixes this issue.


Stefan Lucke
-------------- next part --------------
Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c	(Revision 11292)
+++ libavformat/utils.c	(Arbeitskopie)
@@ -374,6 +374,13 @@
         goto fail;
     }
     ic->iformat = fmt;
+    if (!pb) {
+        pb = av_mallocz(sizeof(ByteIOContext));
+        if(!pb) {
+            err = AVERROR(ENOMEM);
+            goto fail;
+	}
+    }
     ic->pb = pb;
     ic->duration = AV_NOPTS_VALUE;
     ic->start_time = AV_NOPTS_VALUE;



More information about the ffmpeg-devel mailing list