diff mbox

[FFmpeg-devel,2/2] lavf/tcp.c: Free allocated client URLContext in case of error.

Message ID 20170410161046.3424-2-klaxa1337@googlemail.com
State Superseded
Headers show

Commit Message

Stephan Holljes April 10, 2017, 4:10 p.m. UTC
---
 libavformat/tcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Nicolas George April 11, 2017, 9:35 a.m. UTC | #1
Le primidi 21 germinal, an CCXXV, Stephan Holljes a écrit :
> ---
>  libavformat/tcp.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Both patches LGTL. But I do not maintain these files.

Regards,
Stephan Holljes April 11, 2017, 5:12 p.m. UTC | #2
In fact the http patch introduces a bug where it closes the URLContext
regardless of ret. New patches shortly. (Also rebased on Simon's
patches fixing tcp return codes.)

Regards

On Tue, Apr 11, 2017 at 11:35 AM, Nicolas George <george@nsup.org> wrote:
> Le primidi 21 germinal, an CCXXV, Stephan Holljes a écrit :
>> ---
>>  libavformat/tcp.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> Both patches LGTL. But I do not maintain these files.
>
> Regards,
>
> --
>   Nicolas George
Nicolas George April 11, 2017, 5:24 p.m. UTC | #3
Le duodi 22 germinal, an CCXXV, Stephan Holljes a écrit :
> In fact the http patch introduces a bug where it closes the URLContext
> regardless of ret. New patches shortly. (Also rebased on Simon's
> patches fixing tcp return codes.)

You are right, I missed that too.

I suggest to add "return 0;" before "fail:", so that it is really only
for failure.

Regards,
Stephan Holljes April 11, 2017, 6:02 p.m. UTC | #4
On Tue, Apr 11, 2017 at 7:24 PM, Nicolas George <george@nsup.org> wrote:
> Le duodi 22 germinal, an CCXXV, Stephan Holljes a écrit :
>> In fact the http patch introduces a bug where it closes the URLContext
>> regardless of ret. New patches shortly. (Also rebased on Simon's
>> patches fixing tcp return codes.)
>
> You are right, I missed that too.
>
> I suggest to add "return 0;" before "fail:", so that it is really only
> for failure.
>
> Regards,
>
> --
>   Nicolas George
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

I like adding return 0 before fail, it saves a comparison. New patches shortly.

Regards
diff mbox

Patch

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 3055e48..85e500d 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -203,8 +203,10 @@  static int tcp_accept(URLContext *s, URLContext **c)
         return ret;
     cc = (*c)->priv_data;
     ret = ff_accept(sc->fd, sc->listen_timeout, s);
-    if (ret < 0)
+    if (ret < 0) {
+        ffurl_close(*c);
         return ff_neterrno();
+    }
     cc->fd = ret;
     return 0;
 }