[FFmpeg-devel,v2] libavformat/avio: Fix for the unexpected file close which will cause fd 0 is closed

Submitted by lance.lmwang@gmail.com on July 13, 2019, 2:22 p.m.

Details

Message ID 1563027777-17411-1-git-send-email-lance.lmwang@gmail.com
State New
Headers show

Commit Message

lance.lmwang@gmail.com July 13, 2019, 2:22 p.m.
From: Limin Wang <lance.lmwang@gmail.com>

By the code, is_connected is used to check file open or not, so after open_dir
is done, we should not set is_connected to 1, it'll cause the function ffurl_closep 
will invoke the url_close and cause unexpected file close.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/avio.c | 1 -
 1 file changed, 1 deletion(-)

Comments

lance.lmwang@gmail.com Sept. 2, 2019, 1:50 p.m.
ping, have test with the example code.

On Sat, Jul 13, 2019 at 10:22:57PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> By the code, is_connected is used to check file open or not, so after open_dir
> is done, we should not set is_connected to 1, it'll cause the function ffurl_closep 
> will invoke the url_close and cause unexpected file close.
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavformat/avio.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index 663789e..8b52aa3 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -560,7 +560,6 @@ int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options)
>      if (ret < 0)
>          goto fail;
>  
> -    h->is_connected = 1;
>      ctx->url_context = h;
>      *s = ctx;
>      return 0;
> -- 
> 2.6.4
>

Patch hide | download patch | download mbox

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 663789e..8b52aa3 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -560,7 +560,6 @@  int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options)
     if (ret < 0)
         goto fail;
 
-    h->is_connected = 1;
     ctx->url_context = h;
     *s = ctx;
     return 0;