Merge remote-tracking branch 'qatar/release/0.7' into release/0.8
[ffmpeg.git] / libavformat / utils.c
index c990657..955aaa7 100644 (file)
@@ -464,10 +464,16 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
         err = AVERROR(ENOMEM);
         goto fail;
     }
-    ic->pb = pb;
+    if (pb && fmt && fmt->flags & AVFMT_NOFILE)
+        av_log(ic, AV_LOG_WARNING, "Custom AVIOContext makes no sense and "
+                                   "will be ignored with AVFMT_NOFILE format.\n");
+    else
+        ic->pb = pb;
 
-    err = avformat_open_input(ic_ptr, filename, fmt, &opts);
+    err = avformat_open_input(&ic, filename, fmt, &opts);
+    ic->pb = ic->pb ? ic->pb : pb; // don't leak custom pb if it wasn't set above
 
+    *ic_ptr = ic;
 fail:
     av_dict_free(&opts);
     return err;