fix procfs_pargs in the case of an empty argument

This commit is contained in:
Doug MacEachern 2006-04-03 02:17:54 +00:00
parent dbe0355f70
commit 933b7734a6
1 changed files with 3 additions and 4 deletions

View File

@ -269,7 +269,7 @@ int sigar_procfs_args_get(sigar_t *sigar, sigar_pid_t pid,
buf[total] = '\0';
ptr = buf;
while (*ptr) {
while (total > 0) {
int alen = strlen(ptr)+1;
char *arg = malloc(alen);
@ -279,10 +279,9 @@ int sigar_procfs_args_get(sigar_t *sigar, sigar_pid_t pid,
procargs->data[procargs->number++] = arg;
total -= alen;
if (total <= 0) {
break;
if (total > 0) {
ptr += alen;
}
ptr += alen;
}
free(buf);