changeset 100237:44b480d7a129

(procfs_system_process_attributes): Don't use cmd, cmdsize, and q without initializing them first.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 05 Dec 2008 07:07:53 +0000
parents de4bf07955af
children 234b23733f77
files src/process.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/process.c	Fri Dec 05 03:02:03 2008 +0000
+++ b/src/process.c	Fri Dec 05 07:07:53 2008 +0000
@@ -7246,9 +7246,9 @@
   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 @@
       procbuf[nread] = '\0';
       p = procbuf;
 
-      cmd = NULL;
       p = strchr (p, '(');
       if (p != NULL)
 	{
@@ -7312,6 +7311,8 @@
 	      cmdsize = q - cmd;
 	    }
 	}
+      else
+	q = NULL;
       if (cmd == NULL)
 	{
 	  cmd = "???";
@@ -7452,6 +7453,10 @@
 	}
       else
 	{
+	  if (!cmd)
+	    cmd = "???";
+	  if (!cmdsize)
+	    cmdsize = strlen (cmd);
 	  cmdline_size = cmdsize + 2;
 	  cmdline = xmalloc (cmdline_size + 1);
 	  strcpy (cmdline, "[");