Mercurial > libavformat.hg
comparison tcp.c @ 3753:42ed3629601d libavformat
Fix memleak on some OSes in case network initialization fails. See
"[PATCH] tcp.c/udp.c memleak?" for discussion.
author | rbultje |
---|---|
date | Sat, 23 Aug 2008 17:39:56 +0000 |
parents | 4ef51601582d |
children | 8d267b43eaba |
comparison
equal
deleted
inserted
replaced
3752:4ef51601582d | 3753:42ed3629601d |
---|---|
39 int fd_max, ret; | 39 int fd_max, ret; |
40 struct timeval tv; | 40 struct timeval tv; |
41 socklen_t optlen; | 41 socklen_t optlen; |
42 char proto[1024],path[1024],tmp[1024]; | 42 char proto[1024],path[1024],tmp[1024]; |
43 | 43 |
44 if(!ff_network_init()) | |
45 return AVERROR(EIO); | |
46 | |
44 url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), | 47 url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), |
45 &port, path, sizeof(path), uri); | 48 &port, path, sizeof(path), uri); |
46 if (strcmp(proto,"tcp")) goto fail; | 49 if (strcmp(proto,"tcp")) goto fail; |
47 if ((q = strchr(hostname,'@'))) { strcpy(tmp,q+1); strcpy(hostname,tmp); } | 50 if ((q = strchr(hostname,'@'))) { strcpy(tmp,q+1); strcpy(hostname,tmp); } |
48 | 51 |
52 h->priv_data = s; | 55 h->priv_data = s; |
53 h->is_streamed = 1; | 56 h->is_streamed = 1; |
54 | 57 |
55 if (port <= 0 || port >= 65536) | 58 if (port <= 0 || port >= 65536) |
56 goto fail; | 59 goto fail; |
57 | |
58 if(!ff_network_init()) | |
59 return AVERROR(EIO); | |
60 | 60 |
61 dest_addr.sin_family = AF_INET; | 61 dest_addr.sin_family = AF_INET; |
62 dest_addr.sin_port = htons(port); | 62 dest_addr.sin_port = htons(port); |
63 if (resolve_host(&dest_addr.sin_addr, hostname) < 0) | 63 if (resolve_host(&dest_addr.sin_addr, hostname) < 0) |
64 goto fail; | 64 goto fail; |