From bb6c1abb0e022e1edaa5b3d8bb5abdff4f0c0ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 19 Jun 2012 17:50:38 +0300 Subject: [PATCH] tcp: Check the return value from getsockopt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure we actually have an error code in ret, in case getsockopt failed. Signed-off-by: Martin Storsjö --- libavformat/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/tcp.c b/libavformat/tcp.c index e7c6210fc1..f1bad847d0 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -139,7 +139,8 @@ static int tcp_open(URLContext *h, const char *uri, int flags) } /* test error */ optlen = sizeof(ret); - getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen); + if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen)) + ret = AVUNERROR(ff_neterrno()); if (ret != 0) { char errbuf[100]; ret = AVERROR(ret);