From 0733693e194a07aec3a2401bd1c175c452d28fda Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Fri, 13 Jul 2018 10:27:02 +0200 Subject: [PATCH] sadf: SVG: Fix core dumped on buffers reallocation When buffers used to save graphs data needed to be extended to accomodate for new devices, the new size was wrongly calculated and a core dump was then created. Signed-off-by: Sebastien GODARD --- svg_stats.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/svg_stats.c b/svg_stats.c index 3905f17..97bc55b 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -2133,7 +2133,7 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s } if (k == svg_p->nr_max) { /* No free graph entry: Extend all buffers */ - reallocate_all_graph_lines(svg_p->nr_max, + reallocate_all_graph_lines(9 * svg_p->nr_max, &out, &outsize, &spmin, &spmax); svg_p->nr_max *= 2; } @@ -2377,12 +2377,11 @@ __print_funct_t svg_print_net_dev_stats(struct activity *a, int curr, int action } if (k == svg_p->nr_max) { /* No free graph entry: Extend all buffers */ - reallocate_all_graph_lines(svg_p->nr_max, + reallocate_all_graph_lines(9 * svg_p->nr_max, &out, &outsize, &spmin, &spmax); svg_p->nr_max *= 2; } } - pos = k * 9; unregistered = outsize + pos + 8; @@ -2593,7 +2592,7 @@ __print_funct_t svg_print_net_edev_stats(struct activity *a, int curr, int actio } if (k == svg_p->nr_max) { /* No free graph entry: Extend all buffers */ - reallocate_all_graph_lines(svg_p->nr_max, + reallocate_all_graph_lines(10 * svg_p->nr_max, &out, &outsize, &spmin, &spmax); svg_p->nr_max *= 2; } @@ -4718,8 +4717,9 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act } if (k == svg_p->nr_max) { /* No free graph entry: Extend all buffers */ - reallocate_all_graph_lines(svg_p->nr_max, + reallocate_all_graph_lines(9 * svg_p->nr_max, &out, &outsize, &spmin, &spmax); + item_name = *(out + k * 9 + 7); svg_p->nr_max *= 2; } } @@ -4961,7 +4961,7 @@ __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action, } if (k == svg_p->nr_max) { /* No free graph entry: Extend all buffers */ - reallocate_all_graph_lines(svg_p->nr_max, + reallocate_all_graph_lines(5 * svg_p->nr_max, &out, &outsize, &spmin, &spmax); svg_p->nr_max *= 2; } -- 2.40.0