proc_args fix: seems not all processes have the terminating \0

This commit is contained in:
Doug MacEachern 2005-10-07 23:25:36 +00:00
parent fadcfdcbf5
commit cd8cab425e
1 changed files with 6 additions and 7 deletions

View File

@ -225,12 +225,7 @@ int sigar_procfs_args_get(sigar_t *sigar, sigar_pid_t pid,
if (len == 0) {
break;
}
if (buf) {
buf = realloc(buf, total+len);
}
else {
buf = malloc(len+1);
}
buf = realloc(buf, total+len+1);
memcpy(buf+total, buffer, len);
total += len;
}
@ -257,6 +252,10 @@ int sigar_procfs_args_get(sigar_t *sigar, sigar_pid_t pid,
procargs->data[procargs->number++] = arg;
total -= alen;
if (total <= 0) {
break;
}
ptr += alen;
}