]> git.eshelyaron.com Git - emacs.git/commitdiff
(procfs_system_process_attributes): Don't use cmd, cmdsize, and q without
authorEli Zaretskii <eliz@gnu.org>
Fri, 5 Dec 2008 07:09:16 +0000 (07:09 +0000)
committerEli Zaretskii <eliz@gnu.org>
Fri, 5 Dec 2008 07:09:16 +0000 (07:09 +0000)
initializing them first.

src/ChangeLog
src/process.c

index c6cedc1acd2e1555762cdc163d60c9a871e2bd4a..6a40e75226c59014a71c41006ad3c8569dbdb580 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-05  Eli Zaretskii  <eliz@gnu.org>
+
+       * process.c (procfs_system_process_attributes): Don't use cmd,
+       cmdsize, and q without initializing them first.
+
 2008-12-04  Jason Rumney  <jasonr@gnu.org>
 
        * w32font.c (w32font_draw): Initialize orig_clip before getting
index b8e390ed39fa7370b5bf9b4faed460332ba2997e..b5d2f3d4c9f36dae7caf66bedd9c24c34661dc5f 100644 (file)
@@ -7246,9 +7246,9 @@ procfs_system_process_attributes (pid)
   char procbuf[1025], *p, *q;
   int fd;
   ssize_t nread;
-  const char *cmd;
+  const char *cmd = NULL;
   char *cmdline = NULL;
-  size_t cmdsize, cmdline_size;
+  size_t cmdsize = 0, cmdline_size;
   unsigned char c;
   int proc_id, ppid, uid, gid, pgrp, sess, tty, tpgid, thcount;
   unsigned long long utime, stime, cutime, cstime, start;
@@ -7300,7 +7300,6 @@ procfs_system_process_attributes (pid)
       procbuf[nread] = '\0';
       p = procbuf;
 
-      cmd = NULL;
       p = strchr (p, '(');
       if (p != NULL)
        {
@@ -7312,6 +7311,8 @@ procfs_system_process_attributes (pid)
              cmdsize = q - cmd;
            }
        }
+      else
+       q = NULL;
       if (cmd == NULL)
        {
          cmd = "???";
@@ -7452,6 +7453,10 @@ procfs_system_process_attributes (pid)
        }
       else
        {
+         if (!cmd)
+           cmd = "???";
+         if (!cmdsize)
+           cmdsize = strlen (cmd);
          cmdline_size = cmdsize + 2;
          cmdline = xmalloc (cmdline_size + 1);
          strcpy (cmdline, "[");