From 8767060cd2e5f9a29251f90b98b0f0cdafad93ef Mon Sep 17 00:00:00 2001
From: Ramiro Polla <ramiro.polla@gmail.com>
Date: Mon, 21 Apr 2008 01:22:25 +0000
Subject: [PATCH] Fix bug introduced by r12827. If av_exit() was called after
 an AVFormatContext was created, but before its file was opened, av_exit()
 would pass a NULL pointer to url_fclose().

Originally committed as revision 12915 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 ffmpeg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 333f786cf39..51615651106 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -380,7 +380,7 @@ static int av_exit(int ret)
         /* maybe av_close_output_file ??? */
         AVFormatContext *s = output_files[i];
         int j;
-        if (!(s->oformat->flags & AVFMT_NOFILE))
+        if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
             url_fclose(s->pb);
         for(j=0;j<s->nb_streams;j++) {
             av_free(s->streams[j]->codec);
-- 
GitLab