From a657f302f7e07bbb6526ec4dd5823ac9ec0e812a Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Sat, 27 Dec 2014 18:19:55 -0700 Subject: [PATCH] dtsession/SmRestore: fixup 8 coverity issues. --- cde/programs/dtsession/SmRestore.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cde/programs/dtsession/SmRestore.c b/cde/programs/dtsession/SmRestore.c index 30204800..1f556b46 100644 --- a/cde/programs/dtsession/SmRestore.c +++ b/cde/programs/dtsession/SmRestore.c @@ -590,7 +590,7 @@ RestoreState( void ) fileSize = MAXLINE + 1; } - line = (unsigned char *) malloc ((fileSize + 1) * sizeof(char *)); + line = malloc(fileSize + 1); if (line == NULL) { line = fallBackLine; @@ -828,6 +828,8 @@ RestoreResources( Boolean errorHandlerInstalled, ... ) char *argv[20]; va_list args; +#if 0 + /* JET - this seems like a bad (and unused) idea */ /* * Check for alternate resource loader. */ @@ -835,6 +837,9 @@ RestoreResources( Boolean errorHandlerInstalled, ... ) { pgrm = CDE_INSTALLATION_TOP "/bin/dtsession_res"; } +#else + pgrm = CDE_INSTALLATION_TOP "/bin/dtsession_res"; +#endif /* * By convention, exec() wants arg0 to be the program name. Ex: if pgrm @@ -1286,7 +1291,7 @@ RestoreSettings( void ) ptrSize += 50; restorePtrArray = (char **)SM_REALLOC((char *) restorePtrArray, ptrSize * - sizeof(char **)); + sizeof(char *)); if(restorePtrArray == NULL) { PrintErrnoError(DtError, smNLS.cantMallocErrorString); @@ -2065,6 +2070,7 @@ RestoreClients( void ) SM_FREE((char *) remoteBuf[i]); } } + free(displayName); return(-1); } cmdPtr = NULL; @@ -3499,7 +3505,7 @@ StartClient( if (!defaultCwd) { if (getenv ("HOME")) - defaultCwd = strdup (getenv ("HOME")); + defaultCwd = strndup (getenv("HOME"), MAXPATHLEN); else defaultCwd = getcwd (NULL, MAXPATHLEN + 1); -- 2.25.1