From 7d659d4bd624b3100b0c0852039648d7803cbaf9 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 27 Mar 2012 16:53:37 +0200 Subject: Initialize fd correctly with -1 Thanks to Perette Barella. --- src/libwaitress/waitress.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/libwaitress/waitress.c') diff --git a/src/libwaitress/waitress.c b/src/libwaitress/waitress.c index a971487..b2b7d93 100644 --- a/src/libwaitress/waitress.c +++ b/src/libwaitress/waitress.c @@ -1063,6 +1063,7 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) { /* initialize */ memset (&waith->request, 0, sizeof (waith->request)); + waith->request.sockfd = -1; waith->request.dataHandler = WaitressHandleIdentity; waith->request.read = WaitressOrdinaryRead; waith->request.write = WaitressOrdinaryWrite; @@ -1104,7 +1105,9 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) { gnutls_deinit (waith->request.tlsSession); gnutls_certificate_free_credentials (waith->tlsCred); } - close (waith->request.sockfd); + if (waith->request.sockfd != -1) { + close (waith->request.sockfd); + } free (waith->request.buf); if (wRet == WAITRESS_RET_OK && -- cgit v1.2.3