dtsession/SmRestore: fixup 8 coverity issues.
authorJon Trulson <jon@radscan.com>
Sun, 28 Dec 2014 01:19:55 +0000 (18:19 -0700)
committerJon Trulson <jon@radscan.com>
Sun, 28 Dec 2014 01:19:55 +0000 (18:19 -0700)
cde/programs/dtsession/SmRestore.c

index 30204800b221f88f3a1f04d1421556443d17b3a6..1f556b461efaf4dac939890be11bfe4c6b389cd2 100644 (file)
@@ -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);