Commit 27852f2f authored by Anders Nystrom's avatar Anders Nystrom Committed by Luca Barbato

libavformat: Handle error return from ff_listen_bind

Handle error return from ff_listen_bind without leaking file descriptors.
Signed-off-by: 's avatarAnders Nystrom <anders.nystrom@southpole.se>
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent 0266988c
...@@ -114,11 +114,11 @@ static int tcp_open(URLContext *h, const char *uri, int flags) ...@@ -114,11 +114,11 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
} }
if (s->listen) { if (s->listen) {
if ((fd = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen, if ((ret = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
s->listen_timeout, h)) < 0) { s->listen_timeout, h)) < 0) {
ret = fd;
goto fail1; goto fail1;
} }
fd = ret;
} else { } else {
if ((ret = ff_listen_connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen, if ((ret = ff_listen_connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
s->timeout, h, !!cur_ai->ai_next)) < 0) { s->timeout, h, !!cur_ai->ai_next)) < 0) {
......
...@@ -75,12 +75,11 @@ static int unix_open(URLContext *h, const char *filename, int flags) ...@@ -75,12 +75,11 @@ static int unix_open(URLContext *h, const char *filename, int flags)
return ff_neterrno(); return ff_neterrno();
if (s->listen) { if (s->listen) {
fd = ff_listen_bind(fd, (struct sockaddr *)&s->addr, ret = ff_listen_bind(fd, (struct sockaddr *)&s->addr,
sizeof(s->addr), s->timeout, h); sizeof(s->addr), s->timeout, h);
if (fd < 0) { if (ret < 0)
ret = fd;
goto fail; goto fail;
} fd = ret;
} else { } else {
ret = ff_listen_connect(fd, (struct sockaddr *)&s->addr, ret = ff_listen_connect(fd, (struct sockaddr *)&s->addr,
sizeof(s->addr), s->timeout, h, 0); sizeof(s->addr), s->timeout, h, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment