[FFmpeg-cvslog] libavformat: Handle error return from ff_listen_bind
Anders Nystrom
git at videolan.org
Thu Apr 9 20:58:39 CEST 2015
ffmpeg | branch: master | Anders Nystrom <anders.nystrom at southpole.se> | Thu Apr 9 02:38:41 2015 +0200| [27852f2f1dec3749ea79883b70484c841169f747] | committer: Luca Barbato
libavformat: Handle error return from ff_listen_bind
Handle error return from ff_listen_bind without leaking file descriptors.
Signed-off-by: Anders Nystrom <anders.nystrom at southpole.se>
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=27852f2f1dec3749ea79883b70484c841169f747
---
libavformat/tcp.c | 6 +++---
libavformat/unix.c | 9 ++++-----
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 9585dc0..5badf4f 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -114,11 +114,11 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
}
if (s->listen) {
- if ((fd = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
- s->listen_timeout, h)) < 0) {
- ret = fd;
+ if ((ret = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
+ s->listen_timeout, h)) < 0) {
goto fail1;
}
+ fd = ret;
} else {
if ((ret = ff_listen_connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
s->timeout, h, !!cur_ai->ai_next)) < 0) {
diff --git a/libavformat/unix.c b/libavformat/unix.c
index 5c6f576..72b8fcd 100644
--- a/libavformat/unix.c
+++ b/libavformat/unix.c
@@ -75,12 +75,11 @@ static int unix_open(URLContext *h, const char *filename, int flags)
return ff_neterrno();
if (s->listen) {
- fd = ff_listen_bind(fd, (struct sockaddr *)&s->addr,
- sizeof(s->addr), s->timeout, h);
- if (fd < 0) {
- ret = fd;
+ ret = ff_listen_bind(fd, (struct sockaddr *)&s->addr,
+ sizeof(s->addr), s->timeout, h);
+ if (ret < 0)
goto fail;
- }
+ fd = ret;
} else {
ret = ff_listen_connect(fd, (struct sockaddr *)&s->addr,
sizeof(s->addr), s->timeout, h, 0);
More information about the ffmpeg-cvslog
mailing list