summaryrefslogtreecommitdiffstats
path: root/collectors/proc.plugin
diff options
context:
space:
mode:
authorVladimir Kobal <vlad@prokk.net>2019-03-13 18:18:55 +0200
committerGitHub <noreply@github.com>2019-03-13 18:18:55 +0200
commitfb6def2fff1e1d333b94ee7ada25d610aee1708b (patch)
treee06f2f3906c7f76d1c5aeaa0df5fa7b12163ee56 /collectors/proc.plugin
parentb7998ec82d579bd0550e23f880decdcee61264f5 (diff)
Fix memory leaks (#5604)
Diffstat (limited to 'collectors/proc.plugin')
-rw-r--r--collectors/proc.plugin/proc_stat.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/collectors/proc.plugin/proc_stat.c b/collectors/proc.plugin/proc_stat.c
index ad893456b1..f98b095619 100644
--- a/collectors/proc.plugin/proc_stat.c
+++ b/collectors/proc.plugin/proc_stat.c
@@ -404,8 +404,8 @@ static int read_cpuidle_states(char *cpuidle_name_filename , char *cpuidle_time_
}
snprintfz(next_state_filename, FILENAME_MAX, cpuidle_name_filename, core, cc->cpuidle_state_len);
- cc->cpuidle_state = callocz(cc->cpuidle_state_len, sizeof(struct cpuidle_state));
- memset(cc->cpuidle_state, 0, sizeof(struct cpuidle_state) * cc->cpuidle_state_len);
+ if(likely(cc->cpuidle_state_len))
+ cc->cpuidle_state = callocz(cc->cpuidle_state_len, sizeof(struct cpuidle_state));
for(state = 0; state < cc->cpuidle_state_len; state++) {
char name_buf[50 + 1];