fix memory leack in cgroups
Costa Tsaousis (ktsaou) committed
Apr 26, 2016 at 20:06 UTC
d0c6ead065849d8384ad70fec1c199581538cdb0
1 file changed
+6
-5
src/sys_fs_cgroup.c
+6
-5
@@ -241,12 +241,13 @@ void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) {
241
242
if(i != ca->cpus) {
243
free(ca->cpu_percpu);
244
- }
245
- ca->cpu_percpu = malloc(sizeof(unsigned long long) * i);
246
- if(!ca->cpu_percpu)
247
- fatal("Cannot allocate memory (%z bytes)", sizeof(unsigned long long) * i);
244
249
- ca->cpus = i;
245
+ ca->cpu_percpu = malloc(sizeof(unsigned long long) * i);
246
+ if(!ca->cpu_percpu)
247
+ fatal("Cannot allocate memory (%z bytes)", sizeof(unsigned long long) * i);
248
+
249
+ ca->cpus = i;
250
+ }
251
252
for(i = 0; i < ca->cpus ;i++) {
253
ca->cpu_percpu[i] = strtoull(procfile_lineword(ff, 0, i), NULL, 10);