Bug #6956: Fix crash when removing session leader before its children.

(Rich Coe)
This commit is contained in:
Daniel Stone 2006-06-03 10:54:38 +00:00
parent cd384af305
commit ee71cb61f8
2 changed files with 16 additions and 9 deletions

View File

@ -8,6 +8,10 @@
* hw/xfree86/loader/loader.c: * hw/xfree86/loader/loader.c:
Completely remove relocation pointer tables. Completely remove relocation pointer tables.
* Xext/appgroup.c:
Bug #6956: Fix crash when removing session leader before its children.
(Rich Coe)
2006-06-01 Adam Jackson <ajax@freedesktop.org> 2006-06-01 Adam Jackson <ajax@freedesktop.org>
* hw/xfree86/common/xf86Init.c: * hw/xfree86/common/xf86Init.c:

View File

@ -100,7 +100,7 @@ int XagAppGroupFree(
if (pAppGrp->leader) if (pAppGrp->leader)
for (i = 0; i < pAppGrp->nclients; i++) { for (i = 0; i < pAppGrp->nclients; i++) {
pAppGrp->clients[i]->appgroup = NULL; if (pAppGrp->clients[i] == NULL) continue;
CloseDownClient (pAppGrp->clients[i]); CloseDownClient (pAppGrp->clients[i]);
} }
@ -134,6 +134,7 @@ void XagClientStateChange(
ClientPtr pClient = pci->client; ClientPtr pClient = pci->client;
AppGroupPtr pAppGrp; AppGroupPtr pAppGrp;
XID authId = 0; XID authId = 0;
int slot;
if (!pClient->appgroup) { if (!pClient->appgroup) {
switch (pClient->clientState) { switch (pClient->clientState) {
@ -195,16 +196,22 @@ void XagClientStateChange(
case ClientStateInitial: case ClientStateInitial:
case ClientStateCheckedSecurity: case ClientStateCheckedSecurity:
slot = -1;
/* see the comment above about Initial vs. CheckedSecurity */ /* see the comment above about Initial vs. CheckedSecurity */
{ if (pAppGrp->nclients != 0) {
/* if this client already in AppGroup, don't add it again */ /* if this client already in AppGroup, don't add it again */
int i; int i;
for (i = 0; i < pAppGrp->nclients; i++) for (i = 0; i < pAppGrp->nclients; i++)
if (pClient == pAppGrp->clients[i]) return; if (pClient == pAppGrp->clients[i]) return;
if (slot == -1 && pAppGrp->clients[i] == NULL)
slot = i;
} }
pAppGrp->clients = (ClientPtr*) xrealloc (pAppGrp->clients, if (slot == -1) {
++pAppGrp->nclients * sizeof (ClientPtr)); slot = pAppGrp->nclients++;
pAppGrp->clients[pAppGrp->nclients - 1] = pClient; pAppGrp->clients = (ClientPtr*) xrealloc (pAppGrp->clients,
pAppGrp->nclients * sizeof (ClientPtr));
}
pAppGrp->clients[slot] = pClient;
pClient->appgroup = pAppGrp; pClient->appgroup = pAppGrp;
break; break;
@ -217,10 +224,6 @@ void XagClientStateChange(
pAppGrp->clients[i] = NULL; pAppGrp->clients[i] = NULL;
break; break;
} }
for (i = 0; i < pAppGrp->nclients; i++)
if (pAppGrp->clients[i] == NULL && i + 1 < pAppGrp->nclients)
pAppGrp->clients[i] = pAppGrp->clients[i + 1];
pAppGrp->nclients--;
} }
pClient->appgroup = NULL; /* redundant, pClient will be freed */ pClient->appgroup = NULL; /* redundant, pClient will be freed */
break; break;