diff mbox

[FFmpeg-devel] avformat/ftp: Solve a crash bug when network occur a exception

Message ID 1489905719-8132-1-git-send-email-tiejun.peng@foxmail.com
State Superseded
Headers show

Commit Message

tiejun.peng March 19, 2017, 6:41 a.m. UTC
This fixes a proble where ffmpeg would cause crash to do a seek when the network disconnect.
The log like this:
01-01 10:53:03.441  6580  6580 F DEBUG   : backtrace:
01-01 10:53:03.441  6580  6580 F DEBUG   :     #00 pc 0002942e  /system/lib/libavformat.so (ffurl_write+9)

Signed-off-by: tiejun.peng <tiejun.peng@foxmail.com>
---
 libavformat/ftp.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Nicolas George March 19, 2017, 9:37 p.m. UTC | #1
Le nonidi 29 ventôse, an CCXXV, tiejun.peng a écrit :
> This fixes a proble where ffmpeg would cause crash to do a seek when the network disconnect.
> The log like this:
> 01-01 10:53:03.441  6580  6580 F DEBUG   : backtrace:
> 01-01 10:53:03.441  6580  6580 F DEBUG   :     #00 pc 0002942e  /system/lib/libavformat.so (ffurl_write+9)
> 
> Signed-off-by: tiejun.peng <tiejun.peng@foxmail.com>
> ---
>  libavformat/ftp.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/ftp.c b/libavformat/ftp.c
> index 0663b47..3f1bf2e 100644
> --- a/libavformat/ftp.c
> +++ b/libavformat/ftp.c
> @@ -206,6 +206,9 @@ static int ftp_send_command(FTPContext *s, const char *command,
>      if (response)
>          *response = NULL;
>  
> +    if (!s->conn_control)

> +        return -1;

I think -1 is not an acceptable error code here.

> +
>      if ((err = ffurl_write(s->conn_control, command, strlen(command))) < 0)
>          return err;
>      if (!err)

Regards,
diff mbox

Patch

diff --git a/libavformat/ftp.c b/libavformat/ftp.c
index 0663b47..3f1bf2e 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -206,6 +206,9 @@  static int ftp_send_command(FTPContext *s, const char *command,
     if (response)
         *response = NULL;
 
+    if (!s->conn_control)
+        return -1;
+
     if ((err = ffurl_write(s->conn_control, command, strlen(command))) < 0)
         return err;
     if (!err)