From 1e06fbed4726cfb64dbbb17e7bd11f4f4abc5f30 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen Date: Wed, 27 May 2015 16:24:28 +0300 Subject: [PATCH] Fix a crash --- os/connection.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/os/connection.c b/os/connection.c index c05546f..0c50350 100644 --- a/os/connection.c +++ b/os/connection.c @@ -774,6 +774,36 @@ CheckConnections(void) } +static void FreeOsBuffers(OsCommPtr oc) { + ConnectionInputPtr oci; + ConnectionOutputPtr oco; + + if (AvailableInput == oc) + AvailableInput = (OsCommPtr)NULL; + if ((oci = oc->input)) { + if (FreeInputs) { + free(oci->buffer); + free(oci); + } else { + FreeInputs = oci; + oci->next = (ConnectionInputPtr)NULL; + oci->bufptr = oci->buffer; + oci->bufcnt = 0; + oci->lenLastReq = 0; + } + } + if ((oco = oc->output)) { + if (FreeOutputs) { + free(oco->buf); + free(oco); + } else { + FreeOutputs = oco; + oco->next = (ConnectionOutputPtr)NULL; + oco->count = 0; + } + } +} + /***************** * CloseDownConnection * Delete client from AllClients and free resources @@ -790,6 +820,7 @@ CloseDownConnection(ClientPtr client) XdmcpCloseDisplay(oc->fd); #endif CloseDownFileDescriptor(oc); + FreeOsBuffers(oc); client->osPrivate = (pointer)NULL; if (auditTrailLevel > 1) AuditF("client %d disconnected\n", client->index);