Commit 9ea88717 authored by Jamey Sharp's avatar Jamey Sharp Committed by Mike Gabriel

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. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=27497Signed-off-by: 's avatarJamey Sharp <jamey@minilop.net> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: 's avatarJulien Cristau <jcristau@debian.org> Reviewed-by: 's avatarAdam Jackson <ajax@redhat.com> Backport to nx-libs: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
parent 320a8cc0
......@@ -467,8 +467,6 @@ SendScreenSaverNotify (pScreen, state, 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;
......
......@@ -310,15 +310,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);
}
FreeResource(pEventClient->resource, RT_NONE);
}
......
......@@ -969,8 +969,6 @@ SendShapeNotify (pWin, 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;
......
......@@ -563,18 +563,15 @@ SyncSendAlarmNotifyEvents(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 (!pAlarm->client->clientGone)
{
ane.sequenceNumber = pcl->client->sequence;
WriteEventsToClient(pcl->client, 1, (xEvent *) &ane);
}
}
}
......
......@@ -69,7 +69,6 @@ DamageExtNotify (DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes)
ev.area.y = pBoxes[i].y1;
ev.area.width = pBoxes[i].x2 - pBoxes[i].x1;
ev.area.height = pBoxes[i].y2 - pBoxes[i].y1;
if (!pClient->clientGone)
WriteEventsToClient (pClient, 1, (xEvent *) &ev);
}
}
......@@ -79,7 +78,6 @@ DamageExtNotify (DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes)
ev.area.y = 0;
ev.area.width = pDrawable->width;
ev.area.height = pDrawable->height;
if (!pClient->clientGone)
WriteEventsToClient (pClient, 1, (xEvent *) &ev);
}
/* Composite extension marks clients with manual Subwindows as critical */
......
......@@ -4439,6 +4439,9 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
xEvent eventTo, *eventFrom;
int i;
if (!pClient || pClient == serverClient || pClient->clientGone)
return;
#ifdef XKB
if ((!noXkbExtension)&&(!XkbFilterEvents(pClient, count, events)))
return;
......
......@@ -859,14 +859,16 @@ SetCriticalOutputPending(void)
int
WriteToClient (ClientPtr who, int count, char *buf)
{
OsCommPtr oc = (OsCommPtr)who->osPrivate;
ConnectionOutputPtr oco = oc->output;
OsCommPtr oc;
ConnectionOutputPtr oco;
int padBytes;
#ifdef DEBUG_COMMUNICATION
Bool multicount = FALSE;
#endif
if (!count)
if (!count || !who || who == serverClient || who->clientGone)
return(0);
oc = who->osPrivate;
oco = oc->output;
#ifdef DEBUG_COMMUNICATION
{
char info[128];
......
......@@ -96,8 +96,7 @@ CursorDisplayCursor (ScreenPtr pScreen,
CursorCurrent = pCursor;
for (e = cursorEvents; e; e = e->next)
{
if ((e->eventMask & XFixesDisplayCursorNotifyMask) &&
!e->pClient->clientGone)
if ((e->eventMask & XFixesDisplayCursorNotifyMask))
{
xXFixesCursorNotifyEvent ev;
ev.type = XFixesEventBase + XFixesCursorNotify;
......
......@@ -79,8 +79,7 @@ XFixesSelectionCallback (CallbackListPtr *callbacks, void * data, void * args)
for (e = selectionEvents; e; e = e->next)
{
if (e->selection == selection->selection &&
(e->eventMask & eventMask) &&
!e->pClient->clientGone)
(e->eventMask & eventMask))
{
xXFixesSelectionNotifyEvent ev;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment