From 08dd403dbdd4c38b59904b8930b703505eedefd8 Mon Sep 17 00:00:00 2001 From: Michal Jastrzebski Date: Tue, 9 May 2017 07:23:29 +0200 Subject: [PATCH] app/procinfo: fix xstats by ID on 32-bit Coverity reported that an argument for sizeof was used improperly. We should allocate memory for value size that pointer points to, instead of pointer size itself. Coverity issue: 144523, 144521 Fixes: 7ac16a3660c0 ("app/proc-info: support xstats by ID and by name") Signed-off-by: Michal Jastrzebski Acked-by: Harry van Haaren --- app/proc_info/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/proc_info/main.c b/app/proc_info/main.c index 17a1c87494..d4f6a8236e 100644 --- a/app/proc_info/main.c +++ b/app/proc_info/main.c @@ -434,7 +434,7 @@ nic_xstats_by_ids_display(uint8_t port_id, uint64_t *ids, int len) int ret, i; static const char *nic_stats_border = "########################"; - values = malloc(sizeof(values) * len); + values = malloc(sizeof(*values) * len); if (values == NULL) { printf("Cannot allocate memory for xstats\n"); return; @@ -486,7 +486,7 @@ nic_xstats_display(uint8_t port_id) printf("Cannot get xstats count\n"); return; } - values = malloc(sizeof(values) * len); + values = malloc(sizeof(*values) * len); if (values == NULL) { printf("Cannot allocate memory for xstats\n"); return; -- 2.20.1