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: 7ac16a3660 ("app/proc-info: support xstats by ID and by name")

Signed-off-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
This commit is contained in:
Michal Jastrzebski 2017-05-09 07:23:29 +02:00 committed by Thomas Monjalon
parent b6b63dfd0f
commit 08dd403dbd

View File

@ -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;