Make WriteEventsToClient/WriteToClient no-op on fake or dead clients.

This matches the test in TryClientEvents, and is a superset of tests
done by the callers of these functions. The consequence of forgetting
these tests is a server crash, so they're always desirable. In my
opinion, it's better to not require the callers to remember to do these
checks.

For callers that don't do very much work before calling WriteToClient or
WriteEventsToClient, I've removed the redundant checks.

hw/xquartz/xpr/appledri.c has an interesting case: While its check for
"client == NULL" appears redundant with the test in WriteEventsToClient,
it dereferences client to get the sequence number.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=27497
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Jamey Sharp
2010-05-15 12:31:34 -07:00
parent ee9cd2df4a
commit 4b9600a416
16 changed files with 25 additions and 50 deletions

View File

@@ -500,8 +500,6 @@ SendScreenSaverNotify (ScreenPtr pScreen, int state, Bool forced)
for (pEv = pPriv->events; pEv; pEv = pEv->next)
{
client = pEv->client;
if (client->clientGone)
continue;
if (!(pEv->mask & mask))
continue;
ev.type = ScreenSaverNotify + ScreenSaverEventBase;

View File

@@ -199,15 +199,11 @@ SecurityDeleteAuthorization(
{
/* send revocation event event */
ClientPtr client = rClient(pEventClient);
if (!client->clientGone)
{
xSecurityAuthorizationRevokedEvent are;
are.type = SecurityEventBase + XSecurityAuthorizationRevoked;
are.sequenceNumber = client->sequence;
are.authId = pAuth->id;
WriteEventsToClient(client, 1, (xEvent *)&are);
}
xSecurityAuthorizationRevokedEvent are;
are.type = SecurityEventBase + XSecurityAuthorizationRevoked;
are.sequenceNumber = client->sequence;
are.authId = pAuth->id;
WriteEventsToClient(client, 1, (xEvent *)&are);
FreeResource(pEventClient->resource, RT_NONE);
}

View File

@@ -941,8 +941,6 @@ SendShapeNotify (WindowPtr pWin, int which)
}
for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
client = pShapeEvent->client;
if (client == serverClient || client->clientGone)
continue;
se.type = ShapeNotify + ShapeEventBase;
se.kind = which;
se.window = pWin->drawable.id;

View File

@@ -390,17 +390,14 @@ SyncSendAlarmNotifyEvents(SyncAlarm *pAlarm)
ane.state = pAlarm->state;
/* send to owner */
if (pAlarm->events && !pAlarm->client->clientGone)
if (pAlarm->events)
WriteEventsToClient(pAlarm->client, 1, (xEvent *) &ane);
/* send to other interested clients */
for (pcl = pAlarm->pEventClients; pcl; pcl = pcl->next)
{
if (!pcl->client->clientGone)
{
ane.sequenceNumber = pcl->client->sequence;
WriteEventsToClient(pcl->client, 1, (xEvent *) &ane);
}
ane.sequenceNumber = pcl->client->sequence;
WriteEventsToClient(pcl->client, 1, (xEvent *) &ane);
}
}

View File

@@ -59,8 +59,7 @@ xcalibrate_event_hook (int x, int y, int pressure, void *closure)
ev.y = y;
ev.pressure = pressure;
if (!pClient->clientGone)
WriteEventsToClient (pClient, 1, (xEvent *) &ev);
WriteEventsToClient (pClient, 1, (xEvent *) &ev);
}
static int