ffserver.c:558: error: Resource Leak
  resource acquired to `return` by call to `socket_open_listen()` at line 550, column 21 is not released after line 558, column 13.

ffserver.c:542:1: start of procedure http_server()
540. 
541. /* main loop of the http server */
542. static int http_server(void)
     ^
543. {
544.     int server_fd = 0, rtsp_server_fd = 0;

ffserver.c:544:5: 
542. static int http_server(void)
543. {
544.     int server_fd = 0, rtsp_server_fd = 0;
         ^
545.     int ret, delay, delay1;
546.     struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 2], *poll_entry;

ffserver.c:549:9: Taking true branch
547.     HTTPContext *c, *c_next;
548. 
549.     if (my_http_addr.sin_port) {
             ^
550.         server_fd = socket_open_listen(&my_http_addr);
551.         if (server_fd < 0)

ffserver.c:550:9: 
548. 
549.     if (my_http_addr.sin_port) {
550.         server_fd = socket_open_listen(&my_http_addr);
             ^
551.         if (server_fd < 0)
552.             return -1;

ffserver.c:455:1: start of procedure socket_open_listen()
  453. 
  454. /* open a listening socket */
  455. static int socket_open_listen(struct sockaddr_in *my_addr)
       ^
  456. {
  457.     int server_fd, tmp;

ffserver.c:459:5: 
  457.     int server_fd, tmp;
  458. 
  459.     server_fd = socket(AF_INET,SOCK_STREAM,0);
           ^
  460.     if (server_fd < 0) {
  461.         perror ("socket");

ffserver.c:460:9: Taking false branch
  458. 
  459.     server_fd = socket(AF_INET,SOCK_STREAM,0);
  460.     if (server_fd < 0) {
               ^
  461.         perror ("socket");
  462.         return -1;

ffserver.c:465:5: 
  463.     }
  464. 
  465.     tmp = 1;
           ^
  466.     setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));
  467. 

ffserver.c:466:5: Skipping setsockopt(): method has no implementation
  464. 
  465.     tmp = 1;
  466.     setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));
           ^
  467. 
  468.     if (bind (server_fd, (struct sockaddr *) my_addr, sizeof (*my_addr)) < 0) {

ffserver.c:468:9: Taking false branch
  466.     setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));
  467. 
  468.     if (bind (server_fd, (struct sockaddr *) my_addr, sizeof (*my_addr)) < 0) {
               ^
  469.         char bindmsg[32];
  470.         snprintf(bindmsg, sizeof(bindmsg), "bind(port %d)", ntohs(my_addr->sin_port));

ffserver.c:476:9: Taking false branch
  474.     }
  475. 
  476.     if (listen (server_fd, 5) < 0) {
               ^
  477.         perror ("listen");
  478.         closesocket(server_fd);

ffserver.c:481:5: 
  479.         return -1;
  480.     }
  481.     ff_socket_nonblock(server_fd, 1);
           ^
  482. 
  483.     return server_fd;

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. 

ffserver.c:483:5: 
  481.     ff_socket_nonblock(server_fd, 1);
  482. 
  483.     return server_fd;
           ^
  484. }
  485. 

ffserver.c:484:1: return from a call to socket_open_listen
  482. 
  483.     return server_fd;
  484. }
       ^
  485. 
  486. /* start all multicast streams */

ffserver.c:551:13: Taking false branch
549.     if (my_http_addr.sin_port) {
550.         server_fd = socket_open_listen(&my_http_addr);
551.         if (server_fd < 0)
                 ^
552.             return -1;
553.     }

ffserver.c:555:9: Taking true branch
553.     }
554. 
555.     if (my_rtsp_addr.sin_port) {
             ^
556.         rtsp_server_fd = socket_open_listen(&my_rtsp_addr);
557.         if (rtsp_server_fd < 0)

ffserver.c:556:9: 
554. 
555.     if (my_rtsp_addr.sin_port) {
556.         rtsp_server_fd = socket_open_listen(&my_rtsp_addr);
             ^
557.         if (rtsp_server_fd < 0)
558.             return -1;

ffserver.c:455:1: start of procedure socket_open_listen()
  453. 
  454. /* open a listening socket */
  455. static int socket_open_listen(struct sockaddr_in *my_addr)
       ^
  456. {
  457.     int server_fd, tmp;

ffserver.c:459:5: 
  457.     int server_fd, tmp;
  458. 
  459.     server_fd = socket(AF_INET,SOCK_STREAM,0);
           ^
  460.     if (server_fd < 0) {
  461.         perror ("socket");

ffserver.c:460:9: Taking true branch
  458. 
  459.     server_fd = socket(AF_INET,SOCK_STREAM,0);
  460.     if (server_fd < 0) {
               ^
  461.         perror ("socket");
  462.         return -1;

ffserver.c:461:9: 
  459.     server_fd = socket(AF_INET,SOCK_STREAM,0);
  460.     if (server_fd < 0) {
  461.         perror ("socket");
               ^
  462.         return -1;
  463.     }

ffserver.c:462:9: 
  460.     if (server_fd < 0) {
  461.         perror ("socket");
  462.         return -1;
               ^
  463.     }
  464. 

ffserver.c:484:1: return from a call to socket_open_listen
  482. 
  483.     return server_fd;
  484. }
       ^
  485. 
  486. /* start all multicast streams */

ffserver.c:557:13: Taking true branch
555.     if (my_rtsp_addr.sin_port) {
556.         rtsp_server_fd = socket_open_listen(&my_rtsp_addr);
557.         if (rtsp_server_fd < 0)
                 ^
558.             return -1;
559.     }

ffserver.c:558:13: 
556.         rtsp_server_fd = socket_open_listen(&my_rtsp_addr);
557.         if (rtsp_server_fd < 0)
558.             return -1;
                 ^
559.     }
560. 

static int http_server(void)
{
    int server_fd = 0, rtsp_server_fd = 0;
    int ret, delay, delay1;
    struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 2], *poll_entry;
    HTTPContext *c, *c_next;
    if (my_http_addr.sin_port) {
        server_fd = socket_open_listen(&my_http_addr);
        if (server_fd < 0)
            return -1;
    }
    if (my_rtsp_addr.sin_port) {
        rtsp_server_fd = socket_open_listen(&my_rtsp_addr);
        if (rtsp_server_fd < 0)
            return -1;
    }
    if (!rtsp_server_fd && !server_fd) {
        http_log("HTTP and RTSP disabled.\n");
        return -1;
    }
    http_log("ffserver started.\n");
    start_children(first_feed);
    start_multicast();
    for(;;) {
        poll_entry = poll_table;
        if (server_fd) {
            poll_entry->fd = server_fd;
            poll_entry->events = POLLIN;
            poll_entry++;
        }
        if (rtsp_server_fd) {
            poll_entry->fd = rtsp_server_fd;
            poll_entry->events = POLLIN;
            poll_entry++;
        }
        c = first_http_ctx;
        delay = 1000;
        while (c != NULL) {
            int fd;
            fd = c->fd;
            switch(c->state) {
            case HTTPSTATE_SEND_HEADER:
            case RTSPSTATE_SEND_REPLY:
            case RTSPSTATE_SEND_PACKET:
                c->poll_entry = poll_entry;
                poll_entry->fd = fd;
                poll_entry->events = POLLOUT;
                poll_entry++;
                break;
            case HTTPSTATE_SEND_DATA_HEADER:
            case HTTPSTATE_SEND_DATA:
            case HTTPSTATE_SEND_DATA_TRAILER:
                if (!c->is_packetized) {
                    c->poll_entry = poll_entry;
                    poll_entry->fd = fd;
                    poll_entry->events = POLLOUT;
                    poll_entry++;
                } else {
                    delay1 = 10;
                    if (delay1 < delay)
                        delay = delay1;
                }
                break;
            case HTTPSTATE_WAIT_REQUEST:
            case HTTPSTATE_RECEIVE_DATA:
            case HTTPSTATE_WAIT_FEED:
            case RTSPSTATE_WAIT_REQUEST:
                c->poll_entry = poll_entry;
                poll_entry->fd = fd;
                poll_entry->events = POLLIN;
                poll_entry++;
                break;
            default:
                c->poll_entry = NULL;
                break;
            }
            c = c->next;
        }
        do {
            ret = poll(poll_table, poll_entry - poll_table, delay);
            if (ret < 0 && ff_neterrno() != FF_NETERROR(EAGAIN) &&
                ff_neterrno() != FF_NETERROR(EINTR))
                return -1;
        } while (ret < 0);
        cur_time = av_gettime() / 1000;
        if (need_to_start_children) {
            need_to_start_children = 0;
            start_children(first_feed);
        }
        for(c = first_http_ctx; c != NULL; c = c_next) {
            c_next = c->next;
            if (handle_connection(c) < 0) {
                log_connection(c);
                close_connection(c);
            }
        }
        poll_entry = poll_table;
        if (server_fd) {
            if (poll_entry->revents & POLLIN)
                new_connection(server_fd, 0);
            poll_entry++;
        }
        if (rtsp_server_fd) {
            if (poll_entry->revents & POLLIN)
                new_connection(rtsp_server_fd, 1);
        }
    }
}
['static int http_server(void)\n{\n    int server_fd = 0, rtsp_server_fd = 0;\n    int ret, delay, delay1;\n    struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 2], *poll_entry;\n    HTTPContext *c, *c_next;\n    if (my_http_addr.sin_port) {\n        server_fd = socket_open_listen(&my_http_addr);\n        if (server_fd < 0)\n            return -1;\n    }\n    if (my_rtsp_addr.sin_port) {\n        rtsp_server_fd = socket_open_listen(&my_rtsp_addr);\n        if (rtsp_server_fd < 0)\n            return -1;\n    }\n    if (!rtsp_server_fd && !server_fd) {\n        http_log("HTTP and RTSP disabled.\\n");\n        return -1;\n    }\n    http_log("ffserver started.\\n");\n    start_children(first_feed);\n    start_multicast();\n    for(;;) {\n        poll_entry = poll_table;\n        if (server_fd) {\n            poll_entry->fd = server_fd;\n            poll_entry->events = POLLIN;\n            poll_entry++;\n        }\n        if (rtsp_server_fd) {\n            poll_entry->fd = rtsp_server_fd;\n            poll_entry->events = POLLIN;\n            poll_entry++;\n        }\n        c = first_http_ctx;\n        delay = 1000;\n        while (c != NULL) {\n            int fd;\n            fd = c->fd;\n            switch(c->state) {\n            case HTTPSTATE_SEND_HEADER:\n            case RTSPSTATE_SEND_REPLY:\n            case RTSPSTATE_SEND_PACKET:\n                c->poll_entry = poll_entry;\n                poll_entry->fd = fd;\n                poll_entry->events = POLLOUT;\n                poll_entry++;\n                break;\n            case HTTPSTATE_SEND_DATA_HEADER:\n            case HTTPSTATE_SEND_DATA:\n            case HTTPSTATE_SEND_DATA_TRAILER:\n                if (!c->is_packetized) {\n                    c->poll_entry = poll_entry;\n                    poll_entry->fd = fd;\n                    poll_entry->events = POLLOUT;\n                    poll_entry++;\n                } else {\n                    delay1 = 10;\n                    if (delay1 < delay)\n                        delay = delay1;\n                }\n                break;\n            case HTTPSTATE_WAIT_REQUEST:\n            case HTTPSTATE_RECEIVE_DATA:\n            case HTTPSTATE_WAIT_FEED:\n            case RTSPSTATE_WAIT_REQUEST:\n                c->poll_entry = poll_entry;\n                poll_entry->fd = fd;\n                poll_entry->events = POLLIN;\n                poll_entry++;\n                break;\n            default:\n                c->poll_entry = NULL;\n                break;\n            }\n            c = c->next;\n        }\n        do {\n            ret = poll(poll_table, poll_entry - poll_table, delay);\n            if (ret < 0 && ff_neterrno() != FF_NETERROR(EAGAIN) &&\n                ff_neterrno() != FF_NETERROR(EINTR))\n                return -1;\n        } while (ret < 0);\n        cur_time = av_gettime() / 1000;\n        if (need_to_start_children) {\n            need_to_start_children = 0;\n            start_children(first_feed);\n        }\n        for(c = first_http_ctx; c != NULL; c = c_next) {\n            c_next = c->next;\n            if (handle_connection(c) < 0) {\n                log_connection(c);\n                close_connection(c);\n            }\n        }\n        poll_entry = poll_table;\n        if (server_fd) {\n            if (poll_entry->revents & POLLIN)\n                new_connection(server_fd, 0);\n            poll_entry++;\n        }\n        if (rtsp_server_fd) {\n            if (poll_entry->revents & POLLIN)\n                new_connection(rtsp_server_fd, 1);\n        }\n    }\n}', 'static int socket_open_listen(struct sockaddr_in *my_addr)\n{\n    int server_fd, tmp;\n    server_fd = socket(AF_INET,SOCK_STREAM,0);\n    if (server_fd < 0) {\n        perror ("socket");\n        return -1;\n    }\n    tmp = 1;\n    setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));\n    if (bind (server_fd, (struct sockaddr *) my_addr, sizeof (*my_addr)) < 0) {\n        char bindmsg[32];\n        snprintf(bindmsg, sizeof(bindmsg), "bind(port %d)", ntohs(my_addr->sin_port));\n        perror (bindmsg);\n        closesocket(server_fd);\n        return -1;\n    }\n    if (listen (server_fd, 5) < 0) {\n        perror ("listen");\n        closesocket(server_fd);\n        return -1;\n    }\n    ff_socket_nonblock(server_fd, 1);\n    return server_fd;\n}', 'int ff_socket_nonblock(int socket, int enable)\n{\n#ifdef HAVE_WINSOCK2_H\n   return ioctlsocket(socket, FIONBIO, &enable);\n#else\n   if (enable)\n      return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);\n   else\n      return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK);\n#endif\n}']