[PATCH xserver 1/2] os: Move OsCommPtr dereference after ignoreCount check

Chris Wilson chris at chris-wilson.co.uk
Wed Feb 10 12:06:23 UTC 2016


Make AttendClient safe to call along the client teardown path (i.e.
after CloseDownConnection which is called before the Client's resources
are freed) by checking the ClientPtr before the OsCommPtr.

References: https://bugs.freedesktop.org/show_bug.cgi?id=94074
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Adam Jackson <ajax at nwnk.net>
---
 os/connection.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/os/connection.c b/os/connection.c
index 4c1ba4b..be3e4d1 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1254,12 +1254,13 @@ void
 IgnoreClient(ClientPtr client)
 {
     OsCommPtr oc = (OsCommPtr) client->osPrivate;
-    int connection = oc->fd;
+    int connection;
 
     client->ignoreCount++;
     if (client->ignoreCount > 1)
         return;
 
+    connection = oc->fd;
     isItTimeToYield = TRUE;
     if (!GrabInProgress || FD_ISSET(connection, &AllClients)) {
         if (FD_ISSET(connection, &ClientsWithInput))
@@ -1291,12 +1292,13 @@ void
 AttendClient(ClientPtr client)
 {
     OsCommPtr oc = (OsCommPtr) client->osPrivate;
-    int connection = oc->fd;
+    int connection;
 
     client->ignoreCount--;
     if (client->ignoreCount)
         return;
 
+    connection = oc->fd;
     if (!GrabInProgress || GrabInProgress == client->index ||
         FD_ISSET(connection, &GrabImperviousClients)) {
         FD_SET(connection, &AllClients);
-- 
2.7.0



More information about the xorg-devel mailing list