diff options
author | Daniel Stone <daniel@fooishbar.org> | 2006-06-03 10:54:38 +0000 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2006-06-03 10:54:38 +0000 |
commit | ee71cb61f8da29bcf36ea4b199d629e34f89b119 (patch) | |
tree | 8a0e4d1050503708335c84cbcdcca75915e22b20 /Xext | |
parent | cd384af3058fe15077c57eccdffed3b61e261e7f (diff) |
Bug #6956: Fix crash when removing session leader before its children.
(Rich Coe)
Diffstat (limited to 'Xext')
-rw-r--r-- | Xext/appgroup.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Xext/appgroup.c b/Xext/appgroup.c index ad4afa9e4..86bd36ecd 100644 --- a/Xext/appgroup.c +++ b/Xext/appgroup.c @@ -100,7 +100,7 @@ int XagAppGroupFree( if (pAppGrp->leader) for (i = 0; i < pAppGrp->nclients; i++) { - pAppGrp->clients[i]->appgroup = NULL; + if (pAppGrp->clients[i] == NULL) continue; CloseDownClient (pAppGrp->clients[i]); } @@ -134,6 +134,7 @@ void XagClientStateChange( ClientPtr pClient = pci->client; AppGroupPtr pAppGrp; XID authId = 0; + int slot; if (!pClient->appgroup) { switch (pClient->clientState) { @@ -195,16 +196,22 @@ void XagClientStateChange( case ClientStateInitial: case ClientStateCheckedSecurity: + slot = -1; /* see the comment above about Initial vs. CheckedSecurity */ - { + if (pAppGrp->nclients != 0) { /* if this client already in AppGroup, don't add it again */ int i; for (i = 0; i < pAppGrp->nclients; i++) if (pClient == pAppGrp->clients[i]) return; + if (slot == -1 && pAppGrp->clients[i] == NULL) + slot = i; + } + if (slot == -1) { + slot = pAppGrp->nclients++; + pAppGrp->clients = (ClientPtr*) xrealloc (pAppGrp->clients, + pAppGrp->nclients * sizeof (ClientPtr)); } - pAppGrp->clients = (ClientPtr*) xrealloc (pAppGrp->clients, - ++pAppGrp->nclients * sizeof (ClientPtr)); - pAppGrp->clients[pAppGrp->nclients - 1] = pClient; + pAppGrp->clients[slot] = pClient; pClient->appgroup = pAppGrp; break; @@ -217,10 +224,6 @@ void XagClientStateChange( pAppGrp->clients[i] = NULL; 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 */ break; |