Merge remote-tracking branch 'qatar/master'
[ffmpeg.git] / libavformat / segment.c
index 8274792..09949d7 100644 (file)
@@ -172,11 +172,13 @@ static int seg_write_header(AVFormatContext *s)
 
 fail:
     if (ret) {
-        oc->streams = NULL;
-        oc->nb_streams = 0;
+        if (oc) {
+            oc->streams = NULL;
+            oc->nb_streams = 0;
+            avformat_free_context(oc);
+        }
         if (seg->list)
             avio_close(seg->pb);
-        avformat_free_context(oc);
     }
     return ret;
 }