mirror of
https://github.com/prometheus/node_exporter
synced 2025-02-06 04:21:42 +00:00
Remember to bzero string
Duplication was caused by malloc returning a region of memory that already had data in it.
This commit is contained in:
parent
c02dcdeb35
commit
9f7822ccdc
@ -82,7 +82,9 @@ getCPUTimes(int *ncpu, char **cputime) {
|
||||
|
||||
// string needs to hold (5*ncpu)(uint64_t + char)
|
||||
// The char is the space between values.
|
||||
*cputime = (char *) malloc((sizeof(uint64_t)+sizeof(char))*(5*(*ncpu)));
|
||||
int cputime_size = (sizeof(uint64_t)+sizeof(char))*(5*(*ncpu));
|
||||
*cputime = (char *) malloc(cputime_size);
|
||||
bzero(*cputime, cputime_size);
|
||||
|
||||
uint64_t user, nice, sys, intr, idle;
|
||||
user = nice = sys = intr = idle = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user