From 3ac7a00c79a39801f497b48385dae580a08c3cf8 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 4 Feb 2008 20:41:00 +0100 Subject: [PATCH] http_send.c: Fix a bug in http_post_select(). If the accept() on the listen_fd fails, we don't have a valid file descriptor but tried to close it anyway. Even worse, the old code dereferenced and then freed the "sc" pointer which isn't inititialized at that point. --- http_send.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/http_send.c b/http_send.c index 40f0c0af..f8ee656b 100644 --- a/http_send.c +++ b/http_send.c @@ -136,8 +136,10 @@ static void http_post_select(fd_set *rfds, __a_unused fd_set *wfds) if (!FD_ISSET(listen_fd, rfds)) return; ret = para_accept(listen_fd, NULL, 0); - if (ret < 0) - goto err_out; + if (ret < 0) { + PARA_ERROR_LOG("%s\n", para_strerror(-ret)); + return; + } sc = para_calloc(sizeof(*sc)); sc->fd = ret; sc->name = make_message("%s", remote_name(sc->fd)); @@ -168,8 +170,7 @@ static void http_post_select(fd_set *rfds, __a_unused fd_set *wfds) return; err_out: PARA_WARNING_LOG("%s\n", para_strerror(-ret)); - if (sc->fd > 0) - close(sc->fd); + close(sc->fd); free(sc); } -- 2.39.2