libavformat/tcp.c:95: error: Resource Leak
  resource acquired to `return` by call to `socket()` at line 56, column 10 is not released after line 95, column 9.

libavformat/tcp.c:32:1: start of procedure tcp_open()
30. 
31. /* return non zero if error */
32. static int tcp_open(URLContext *h, const char *uri, int flags)
    ^
33. {
34.     struct sockaddr_in dest_addr;

libavformat/tcp.c:35:5: 
33. {
34.     struct sockaddr_in dest_addr;
35.     int port, fd = -1;
        ^
36.     TCPContext *s = NULL;
37.     fd_set wfds;

libavformat/tcp.c:36:5: 
34.     struct sockaddr_in dest_addr;
35.     int port, fd = -1;
36.     TCPContext *s = NULL;
        ^
37.     fd_set wfds;
38.     int fd_max, ret;

libavformat/tcp.c:43:9: 
41.     char hostname[1024],proto[1024],path[1024];
42. 
43.     if(!ff_network_init())
            ^
44.         return AVERROR(EIO);
45. 

libavformat/network.h:47:1: start of procedure ff_network_init()
  45. int ff_socket_nonblock(int socket, int enable);
  46. 
  47. static inline int ff_network_init(void)
      ^
  48. {
  49. #ifdef HAVE_WINSOCK2_H

libavformat/network.h:54:5: 
  52.         return 0;
  53. #endif
  54.     return 1;
          ^
  55. }
  56. 

libavformat/network.h:55:1: return from a call to ff_network_init
  53. #endif
  54.     return 1;
  55. }
      ^
  56. 
  57. static inline void ff_network_close(void)

libavformat/tcp.c:43:9: Taking false branch
41.     char hostname[1024],proto[1024],path[1024];
42. 
43.     if(!ff_network_init())
            ^
44.         return AVERROR(EIO);
45. 

libavformat/tcp.c:46:5: Skipping url_split(): empty list of specs
44.         return AVERROR(EIO);
45. 
46.     url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
        ^
47.         &port, path, sizeof(path), uri);
48.     if (strcmp(proto,"tcp") || port <= 0 || port >= 65536)

libavformat/tcp.c:48:9: Taking false branch
46.     url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
47.         &port, path, sizeof(path), uri);
48.     if (strcmp(proto,"tcp") || port <= 0 || port >= 65536)
            ^
49.         return AVERROR(EINVAL);
50. 

libavformat/tcp.c:48:32: Taking false branch
46.     url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
47.         &port, path, sizeof(path), uri);
48.     if (strcmp(proto,"tcp") || port <= 0 || port >= 65536)
                                   ^
49.         return AVERROR(EINVAL);
50. 

libavformat/tcp.c:48:45: Taking false branch
46.     url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
47.         &port, path, sizeof(path), uri);
48.     if (strcmp(proto,"tcp") || port <= 0 || port >= 65536)
                                                ^
49.         return AVERROR(EINVAL);
50. 

libavformat/tcp.c:51:5: 
49.         return AVERROR(EINVAL);
50. 
51.     dest_addr.sin_family = AF_INET;
        ^
52.     dest_addr.sin_port = htons(port);
53.     if (resolve_host(&dest_addr.sin_addr, hostname) < 0)

libavformat/tcp.c:52:5: Skipping htons(): method has no implementation
50. 
51.     dest_addr.sin_family = AF_INET;
52.     dest_addr.sin_port = htons(port);
        ^
53.     if (resolve_host(&dest_addr.sin_addr, hostname) < 0)
54.         return AVERROR(EIO);

libavformat/tcp.c:53:9: 
51.     dest_addr.sin_family = AF_INET;
52.     dest_addr.sin_port = htons(port);
53.     if (resolve_host(&dest_addr.sin_addr, hostname) < 0)
            ^
54.         return AVERROR(EIO);
55. 

libavformat/os_support.c:64:1: start of procedure resolve_host()
  62. 
  63. /* resolve host with also IP address parsing */
  64. int resolve_host(struct in_addr *sin_addr, const char *hostname)
      ^
  65. {
  66.     struct hostent *hp;

libavformat/os_support.c:68:10: Taking true branch
  66.     struct hostent *hp;
  67. 
  68.     if (!inet_aton(hostname, sin_addr)) {
               ^
  69.         hp = gethostbyname(hostname);
  70.         if (!hp)

libavformat/os_support.c:69:9: Skipping gethostbyname(): method has no implementation
  67. 
  68.     if (!inet_aton(hostname, sin_addr)) {
  69.         hp = gethostbyname(hostname);
              ^
  70.         if (!hp)
  71.             return -1;

libavformat/os_support.c:70:14: Taking false branch
  68.     if (!inet_aton(hostname, sin_addr)) {
  69.         hp = gethostbyname(hostname);
  70.         if (!hp)
                   ^
  71.             return -1;
  72.         memcpy(sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));

libavformat/os_support.c:72:9: 
  70.         if (!hp)
  71.             return -1;
  72.         memcpy(sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
              ^
  73.     }
  74.     return 0;

libavformat/os_support.c:74:5: 
  72.         memcpy(sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
  73.     }
  74.     return 0;
          ^
  75. }
  76. 

libavformat/os_support.c:75:1: return from a call to resolve_host
  73.     }
  74.     return 0;
  75. }
      ^
  76. 
  77. int ff_socket_nonblock(int socket, int enable)

libavformat/tcp.c:53:9: Taking false branch
51.     dest_addr.sin_family = AF_INET;
52.     dest_addr.sin_port = htons(port);
53.     if (resolve_host(&dest_addr.sin_addr, hostname) < 0)
            ^
54.         return AVERROR(EIO);
55. 

libavformat/tcp.c:56:5: 
54.         return AVERROR(EIO);
55. 
56.     fd = socket(AF_INET, SOCK_STREAM, 0);
        ^
57.     if (fd < 0)
58.         return AVERROR(EIO);

libavformat/tcp.c:57:9: Taking false branch
55. 
56.     fd = socket(AF_INET, SOCK_STREAM, 0);
57.     if (fd < 0)
            ^
58.         return AVERROR(EIO);
59.     ff_socket_nonblock(fd, 1);

libavformat/tcp.c:59:5: 
57.     if (fd < 0)
58.         return AVERROR(EIO);
59.     ff_socket_nonblock(fd, 1);
        ^
60. 
61.  redo:

libavformat/os_support.c:77:1: start of procedure ff_socket_nonblock()
  75. }
  76. 
  77. int ff_socket_nonblock(int socket, int enable)
      ^
  78. {
  79. #ifdef HAVE_WINSOCK2_H

libavformat/os_support.c:82:8: Taking true branch
  80.    return ioctlsocket(socket, FIONBIO, &enable);
  81. #else
  82.    if (enable)
             ^
  83.       return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);
  84.    else

libavformat/os_support.c:83:7: 
  81. #else
  82.    if (enable)
  83.       return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);
            ^
  84.    else
  85.       return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK);

libavformat/os_support.c:87:1: return from a call to ff_socket_nonblock
  85.       return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK);
  86. #endif
  87. }
      ^
  88. #endif /* CONFIG_NETWORK */
  89. 

libavformat/tcp.c:66:13: 
64.     if (ret < 0) {
65.         if (ff_neterrno() == FF_NETERROR(EINTR))
66.             goto redo;
                ^
67.         if (ff_neterrno() != FF_NETERROR(EINPROGRESS) &&
68.             ff_neterrno() != FF_NETERROR(EAGAIN))

libavformat/tcp.c:62:5: Skipping connect(): method has no implementation
60. 
61.  redo:
62.     ret = connect(fd, (struct sockaddr *)&dest_addr,
        ^
63.                   sizeof(dest_addr));
64.     if (ret < 0) {

libavformat/tcp.c:64:9: Taking true branch
62.     ret = connect(fd, (struct sockaddr *)&dest_addr,
63.                   sizeof(dest_addr));
64.     if (ret < 0) {
            ^
65.         if (ff_neterrno() == FF_NETERROR(EINTR))
66.             goto redo;

libavformat/tcp.c:65:13: Taking false branch
63.                   sizeof(dest_addr));
64.     if (ret < 0) {
65.         if (ff_neterrno() == FF_NETERROR(EINTR))
                ^
66.             goto redo;
67.         if (ff_neterrno() != FF_NETERROR(EINPROGRESS) &&

libavformat/tcp.c:67:13: Taking false branch
65.         if (ff_neterrno() == FF_NETERROR(EINTR))
66.             goto redo;
67.         if (ff_neterrno() != FF_NETERROR(EINPROGRESS) &&
                ^
68.             ff_neterrno() != FF_NETERROR(EAGAIN))
69.             goto fail;

libavformat/tcp.c:85:9: Loop condition is true. Entering loop body
83.             if (ret > 0 && FD_ISSET(fd, &wfds))
84.                 break;
85.         }
            ^
86. 
87.         /* test error */

libavformat/tcp.c:73:17: Taking false branch
71.         /* wait until we are connected or until abort */
72.         for(;;) {
73.             if (url_interrupt_cb()) {
                    ^
74.                 ret = AVERROR(EINTR);
75.                 goto fail1;

libavformat/tcp.c:77:13: 
75.                 goto fail1;
76.             }
77.             fd_max = fd;
                ^
78.             FD_ZERO(&wfds);
79.             FD_SET(fd, &wfds);

libavformat/tcp.c:78:13: Loop condition is true. Entering loop body
76.             }
77.             fd_max = fd;
78.             FD_ZERO(&wfds);
                ^
79.             FD_SET(fd, &wfds);
80.             tv.tv_sec = 0;

libavformat/tcp.c:78:13: Loop condition is false. Leaving loop
76.             }
77.             fd_max = fd;
78.             FD_ZERO(&wfds);
                ^
79.             FD_SET(fd, &wfds);
80.             tv.tv_sec = 0;

libavformat/tcp.c:78:13: Loop condition is false. Leaving loop
76.             }
77.             fd_max = fd;
78.             FD_ZERO(&wfds);
                ^
79.             FD_SET(fd, &wfds);
80.             tv.tv_sec = 0;

libavformat/tcp.c:79:13: 
77.             fd_max = fd;
78.             FD_ZERO(&wfds);
79.             FD_SET(fd, &wfds);
                ^
80.             tv.tv_sec = 0;
81.             tv.tv_usec = 100 * 1000;

libavformat/tcp.c:80:13: 
78.             FD_ZERO(&wfds);
79.             FD_SET(fd, &wfds);
80.             tv.tv_sec = 0;
                ^
81.             tv.tv_usec = 100 * 1000;
82.             ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);

libavformat/tcp.c:81:13: 
79.             FD_SET(fd, &wfds);
80.             tv.tv_sec = 0;
81.             tv.tv_usec = 100 * 1000;
                ^
82.             ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);
83.             if (ret > 0 && FD_ISSET(fd, &wfds))

libavformat/tcp.c:82:13: Skipping select(): method has no implementation
80.             tv.tv_sec = 0;
81.             tv.tv_usec = 100 * 1000;
82.             ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);
                ^
83.             if (ret > 0 && FD_ISSET(fd, &wfds))
84.                 break;

libavformat/tcp.c:83:17: Taking true branch
81.             tv.tv_usec = 100 * 1000;
82.             ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);
83.             if (ret > 0 && FD_ISSET(fd, &wfds))
                    ^
84.                 break;
85.         }

libavformat/tcp.c:83:28: Taking true branch
81.             tv.tv_usec = 100 * 1000;
82.             ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);
83.             if (ret > 0 && FD_ISSET(fd, &wfds))
                               ^
84.                 break;
85.         }

libavformat/tcp.c:88:9: 
86. 
87.         /* test error */
88.         optlen = sizeof(ret);
            ^
89.         getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
90.         if (ret != 0)

libavformat/tcp.c:89:9: Skipping getsockopt(): method has no implementation
87.         /* test error */
88.         optlen = sizeof(ret);
89.         getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
            ^
90.         if (ret != 0)
91.             goto fail;

libavformat/tcp.c:90:13: Taking false branch
88.         optlen = sizeof(ret);
89.         getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
90.         if (ret != 0)
                ^
91.             goto fail;
92.     }

libavformat/tcp.c:93:5: 
91.             goto fail;
92.     }
93.     s = av_malloc(sizeof(TCPContext));
        ^
94.     if (!s)
95.         return AVERROR(ENOMEM);

libavutil/mem.c:42:1: start of procedure av_malloc()
  40.    linker will do it automatically */
  41. 
  42. void *av_malloc(unsigned int size)
      ^
  43. {
  44.     void *ptr;

libavutil/mem.c:50:8: Taking false branch
  48. 
  49.     /* let's disallow possible ambiguous cases */
  50.     if(size > (INT_MAX-16) )
             ^
  51.         return NULL;
  52. 

libavutil/mem.c:61:5: Skipping memalign(): method has no implementation
  59.     ((char*)ptr)[-1]= diff;
  60. #elif defined (HAVE_MEMALIGN)
  61.     ptr = memalign(16,size);
          ^
  62.     /* Why 64?
  63.        Indeed, we should align it:

libavutil/mem.c:91:5: 
  89.     ptr = malloc(size);
  90. #endif
  91.     return ptr;
          ^
  92. }
  93. 

libavutil/mem.c:92:1: return from a call to av_malloc
  90. #endif
  91.     return ptr;
  92. }
      ^
  93. 
  94. void *av_realloc(void *ptr, unsigned int size)

libavformat/tcp.c:94:10: Taking true branch
92.     }
93.     s = av_malloc(sizeof(TCPContext));
94.     if (!s)
             ^
95.         return AVERROR(ENOMEM);
96.     h->priv_data = s;

libavformat/tcp.c:95:9: 
93.     s = av_malloc(sizeof(TCPContext));
94.     if (!s)
95.         return AVERROR(ENOMEM);
            ^
96.     h->priv_data = s;
97.     h->is_streamed = 1;
