1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

dtsession: fix a crash.

This commit is contained in:
hyousatsu 2023-08-16 23:18:47 -04:00
parent b577546819
commit 615d9a3907
2 changed files with 48 additions and 24 deletions

View file

@ -2587,7 +2587,7 @@ SmExit (
smXSMP.saveState.shutdown && smXSMP.saveState.shutdown &&
!smXSMP.saveState.shutdownCanceled) !smXSMP.saveState.shutdownCanceled)
XSMPExit (); XSMPExit ();
exit(exitStatus); _exit(exitStatus);
} }
else else
return; return;

View file

@ -126,9 +126,10 @@ static char *getXSMPResource(ClientData *, int, char *);
static void getClientGeometry(ClientData *, int *, int *, static void getClientGeometry(ClientData *, int *, int *,
unsigned int *, unsigned int *); unsigned int *, unsigned int *);
static Boolean getProxyClientInfo(ClientData *, ProxyClientInfo *); static Boolean getProxyClientInfo(ClientData *, ProxyClientInfo *);
static Bool cmpProxyClientProc(XrmDatabase *, XrmBindingList, static Bool fillClientIDProc(XrmDatabase *, XrmBindingList,
XrmQuarkList, XrmRepresentation *, XrmQuarkList, XrmRepresentation *,
XrmValue *, XPointer); XrmValue *, XPointer);
static Bool cmpProxyClient(char *clientID, ProxyClientInfo *proxyClientInfo);
static char *findProxyClientID(ClientData *); static char *findProxyClientID(ClientData *);
static Boolean findXSMPClientDBMatch(ClientData *, char **); static Boolean findXSMPClientDBMatch(ClientData *, char **);
static Boolean findProxyClientDBMatch(ClientData *, char **); static Boolean findProxyClientDBMatch(ClientData *, char **);
@ -495,21 +496,40 @@ getProxyClientInfo(ClientData *pCD, ProxyClientInfo *proxyClientInfo)
return True; return True;
} }
/*
* IMPORTANT: This function is called by XrmEnumerateDatabase().
* It calls other Xrm*() functions - if dtwm is threaded, THIS
* WILL HANG. For now, dtwm is NOT threaded, so no problem.
*/
static Bool static Bool
cmpProxyClientProc(XrmDatabase *clientDB, XrmBindingList bindingList, fillClientIDProc(XrmDatabase *clientDB, XrmBindingList bindingList,
XrmQuarkList quarkList, XrmRepresentation *reps, XrmQuarkList quarkList, XrmRepresentation *reps,
XrmValue *value, XPointer uData) XrmValue *value, XPointer uData)
{
static int i;
int nList;
char *clientID = value->addr;
char ***pClientIDList = (char ***) uData;
char **clientIDList = *pClientIDList;
if (!(clientID && *clientID)) return FALSE;
if (clientIDList) ++i;
else i = 0;
nList = 2 + i;
if (i < 0 || nList < 2) return TRUE;
*pClientIDList = realloc(*pClientIDList, nList * sizeof(char *));
clientIDList = i + *pClientIDList;
clientIDList[0] = clientID;
clientIDList[1] = NULL;
return FALSE;
}
static Bool
cmpProxyClient(char *clientID, ProxyClientInfo *proxyClientInfo)
{ {
char *clientScreen; char *clientScreen;
char *wmCommand; char *wmCommand;
char *wmClientMachine; char *wmClientMachine;
char *clientID = (char *)value->addr;
ProxyClientInfo *proxyClientInfo = (ProxyClientInfo *)uData;
if (((wmCommand = if (((wmCommand =
getClientResource(clientID, wmCommandStr)) == (char *)NULL) || getClientResource(clientID, wmCommandStr)) == (char *)NULL) ||
@ -525,10 +545,7 @@ cmpProxyClientProc(XrmDatabase *clientDB, XrmBindingList bindingList,
((wmClientMachine = ((wmClientMachine =
getClientResource(clientID, wmClientMachineStr)) == (char *)NULL) || getClientResource(clientID, wmClientMachineStr)) == (char *)NULL) ||
(strcmp(proxyClientInfo->wmClientMachine, wmClientMachine) == 0)) (strcmp(proxyClientInfo->wmClientMachine, wmClientMachine) == 0))
{
proxyClientInfo->clientID = clientID;
return TRUE; return TRUE;
}
return FALSE; return FALSE;
} }
@ -537,7 +554,9 @@ static char *
findProxyClientID(ClientData *pCD) findProxyClientID(ClientData *pCD)
{ {
ProxyClientInfo proxyClientInfo; ProxyClientInfo proxyClientInfo;
char *clientID = (char *)NULL; int i;
char *clientID = NULL;
char **clientIDList = NULL;
static XrmName proxyName[2] = {NULLQUARK, NULLQUARK}; static XrmName proxyName[2] = {NULLQUARK, NULLQUARK};
static XrmClass proxyClass[2] = {NULLQUARK, NULLQUARK}; static XrmClass proxyClass[2] = {NULLQUARK, NULLQUARK};
@ -551,18 +570,23 @@ findProxyClientID(ClientData *pCD)
* We need to match the screen and * We need to match the screen and
* the WM_COMMAND and WM_CLIENT_MACHINE properties. * the WM_COMMAND and WM_CLIENT_MACHINE properties.
*/ */
if (!getProxyClientInfo(pCD, &proxyClientInfo)) if (!getProxyClientInfo(pCD, &proxyClientInfo)) return clientID;
return clientID;
if (XrmEnumerateDatabase(wmGD.clientResourceDB, proxyName, proxyClass, XrmEnumerateDatabase(wmGD.clientResourceDB, proxyName, proxyClass,
XrmEnumOneLevel, cmpProxyClientProc, XrmEnumOneLevel, fillClientIDProc, (XPointer)&clientIDList);
(XPointer)&proxyClientInfo))
clientID = proxyClientInfo.clientID;
if (proxyClientInfo.wmCommand) for (i = 0; clientIDList && clientIDList[i]; ++i)
free(proxyClientInfo.wmCommand); {
if (proxyClientInfo.wmClientMachine) if (cmpProxyClient(clientIDList[i], &proxyClientInfo))
free(proxyClientInfo.wmClientMachine); {
clientID = clientIDList[i];
break;
}
}
if (proxyClientInfo.wmCommand) free(proxyClientInfo.wmCommand);
if (proxyClientInfo.wmClientMachine) free(proxyClientInfo.wmClientMachine);
if (clientIDList) free(clientIDList);
return clientID; return clientID;
} }