aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/tcp.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2008-08-23 17:39:56 +0000
committerRonald S. Bultje <rsbultje@gmail.com>2008-08-23 17:39:56 +0000
commite6c13819825aab796965a96ffb451cd008eab647 (patch)
tree6e45aa7c44cc9bba91337aefdfbf4768a10cf851 /libavformat/tcp.c
parentad33bfefc7e1a0ddc9569bfc480835cf2fd80272 (diff)
downloadffmpeg-e6c13819825aab796965a96ffb451cd008eab647.tar.gz
Fix memleak on some OSes in case network initialization fails. See
"[PATCH] tcp.c/udp.c memleak?" for discussion. Originally committed as revision 14923 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/tcp.c')
-rw-r--r--libavformat/tcp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 957b1adfe7..9191960ca7 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -41,6 +41,9 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
socklen_t optlen;
char proto[1024],path[1024],tmp[1024];
+ if(!ff_network_init())
+ return AVERROR(EIO);
+
url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
&port, path, sizeof(path), uri);
if (strcmp(proto,"tcp")) goto fail;
@@ -55,9 +58,6 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
if (port <= 0 || port >= 65536)
goto fail;
- if(!ff_network_init())
- return AVERROR(EIO);
-
dest_addr.sin_family = AF_INET;
dest_addr.sin_port = htons(port);
if (resolve_host(&dest_addr.sin_addr, hostname) < 0)