proc_args fix: seems not all processes have the terminating \0
This commit is contained in:
parent
fadcfdcbf5
commit
cd8cab425e
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue