change proc_args to break after len is consumed rather than *ptr == \0

This commit is contained in:
Doug MacEachern 2006-04-03 17:48:56 +00:00
parent 1da67e240f
commit 0ea23da2ae
1 changed files with 3 additions and 4 deletions

View File

@ -984,7 +984,7 @@ int sigar_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
buffer[len] = '\0'; buffer[len] = '\0';
while (*ptr) { while (len > 0) {
int alen = strlen(ptr)+1; int alen = strlen(ptr)+1;
char *arg = malloc(alen); char *arg = malloc(alen);
@ -994,11 +994,10 @@ int sigar_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
procargs->data[procargs->number++] = arg; procargs->data[procargs->number++] = arg;
len -= alen; len -= alen;
if (len <= 0) { if (len > 0) {
break;
}
ptr += alen; ptr += alen;
} }
}
return SIGAR_OK; return SIGAR_OK;
#endif #endif